From 18817ccbc0dc2c0824a10a01b158bdeccc81dc06 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 12 Jun 2024 00:30:39 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.305.0 --- .speakeasy/gen.lock | 10 +- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- codeSamples.yaml | 1566 ++++++++++++++++++------------------- jsr.json | 2 +- package-lock.json | 4 +- package.json | 2 +- src/lib/config.ts | 6 +- src/lib/encodings.ts | 46 ++ src/sdk/activities.ts | 4 +- src/sdk/authentication.ts | 20 +- src/sdk/butler.ts | 6 +- src/sdk/hubs.ts | 33 +- src/sdk/library.ts | 53 +- src/sdk/log.ts | 17 +- src/sdk/media.ts | 30 +- src/sdk/playlists.ts | 93 +-- src/sdk/plex.ts | 19 +- src/sdk/search.ts | 40 +- src/sdk/server.ts | 31 +- src/sdk/sessions.ts | 4 +- src/sdk/statistics.ts | 13 +- src/sdk/updater.ts | 26 +- src/sdk/video.ts | 123 +-- 25 files changed, 1039 insertions(+), 1133 deletions(-) diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 8078a95f..b217c12e 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -3,10 +3,10 @@ id: 16f22cbf-f23f-4419-8924-3a4b06381947 management: docChecksum: 911d74baa0d06121d2ce2c71d94e977a docVersion: 0.0.3 - speakeasyVersion: 1.300.0 - generationVersion: 2.338.14 - releaseVersion: 0.16.4 - configChecksum: 1dd152d0b7683cd3ad5f8f7a08553e72 + speakeasyVersion: 1.305.0 + generationVersion: 2.340.3 + releaseVersion: 0.16.5 + configChecksum: 98aaab8d194d47882bda96340ed700a5 repoURL: https://github.com/LukeHagar/plexjs.git repoSubDirectory: . installationURL: https://github.com/LukeHagar/plexjs @@ -15,7 +15,7 @@ features: typescript: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.5 - core: 3.9.12 + core: 3.9.13 flattening: 2.81.1 globalSecurity: 2.82.9 globalSecurityCallbacks: 0.1.0 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 8c86105e..b11d9a49 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.16.4 + version: 0.16.5 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 4af5a6e3..b7fb5d60 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.300.1 +speakeasyVersion: 1.305.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:9d0d908d84211b196f5f826d187e2198c4a0f5c3d455fdf5225db45460f97692 - sourceBlobDigest: sha256:ff6236e7b2254357a72dd0d200f3076fbf74a884c1a9c1aea6f23d90ee6457c1 + sourceRevisionDigest: sha256:3dc012bebc4b164472d5f589b49a3ad940d642475ed297c3047710cecb74b1a2 + sourceBlobDigest: sha256:c21d12547dbe3b1724d05c6cff7586b7f27ebf086d4448fba64b270138fa2499 tags: - latest - main @@ -11,8 +11,8 @@ targets: plexjs: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:9d0d908d84211b196f5f826d187e2198c4a0f5c3d455fdf5225db45460f97692 - sourceBlobDigest: sha256:ff6236e7b2254357a72dd0d200f3076fbf74a884c1a9c1aea6f23d90ee6457c1 + sourceRevisionDigest: sha256:3dc012bebc4b164472d5f589b49a3ad940d642475ed297c3047710cecb74b1a2 + sourceBlobDigest: sha256:c21d12547dbe3b1724d05c6cff7586b7f27ebf086d4448fba64b270138fa2499 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/RELEASES.md b/RELEASES.md index 8fb4eabf..6ac2c89a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -758,4 +758,14 @@ Based on: ### Generated - [typescript v0.16.4] . ### Releases -- [NPM v0.16.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.16.4 - . \ No newline at end of file +- [NPM v0.16.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.16.4 - . + +## 2024-06-12 00:28:55 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.305.0 (2.340.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.16.5] . +### Releases +- [NPM v0.16.5] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.16.5 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index d182e734..b4c20151 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -3,13 +3,14 @@ info: title: CodeSamples overlay for typescript target version: 0.0.0 actions: - - target: $["paths"]["/playlists/{playlistID}"]["get"] + - target: $["paths"]["/playlists"]["post"] update: x-codeSamples: - lang: typescript - label: getPlaylist + label: createPlaylist source: |- import { PlexAPI } from "@lukehagar/plexjs"; + import { QueryParamType, Smart } from "@lukehagar/plexjs/models/operations"; const plexAPI = new PlexAPI({ accessToken: "", @@ -17,172 +18,11 @@ actions: }); async function run() { - const result = await plexAPI.playlists.getPlaylist(4109.48); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/butler"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getButlerTasks - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.butler.getButlerTasks(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/sections"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getLibraries - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.getLibraries(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/sections/{sectionId}"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getLibrary - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { IncludeDetails } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.getLibrary(1000, IncludeDetails.Zero); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/playlists"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getPlaylists - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { PlaylistType, QueryParamSmart } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.playlists.getPlaylists(PlaylistType.Audio, QueryParamSmart.Zero); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/:/prefs"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getServerPreferences - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.server.getServerPreferences(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/:/unscrobble"]["get"] - update: - x-codeSamples: - - lang: typescript - label: markUnplayed - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.media.markUnplayed(59398); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"] - update: - x-codeSamples: - - lang: typescript - label: startUniversalTranscode - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.video.startUniversalTranscode({ - hasMDE: 1, - path: "/library/metadata/23409", - mediaIndex: 0, - partIndex: 0, - protocol: "hls", - fastSeek: 0, - directPlay: 0, - directStream: 0, - subtitleSize: 100, - subtites: "burn", - audioBoost: 100, - location: "lan", - mediaBufferSize: 102400, - session: "zvcage8b7rkioqcm8f4uns4c", - addDebugOverlay: 0, - autoAdjustQuality: 0, + const result = await plexAPI.playlists.createPlaylist({ + title: "", + type: QueryParamType.Photo, + smart: Smart.One, + uri: "https://inborn-brochure.biz", }); // Handle the result @@ -190,11 +30,11 @@ actions: } run(); - - target: $["paths"]["/library/recentlyAdded"]["get"] + - target: $["paths"]["/playlists/{playlistID}"]["delete"] update: x-codeSamples: - lang: typescript - label: getRecentlyAdded + label: deletePlaylist source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -204,7 +44,165 @@ actions: }); async function run() { - const result = await plexAPI.library.getRecentlyAdded(); + const result = await plexAPI.playlists.deletePlaylist(216.22); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/library/sections/{sectionId}/{tag}"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getLibraryItems + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { Tag } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.library.getLibraryItems(1, Tag.Genre); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/library/metadata/{ratingKey}"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getMetadata + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.library.getMetadata(8382.31); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/pins/{pinID}"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getToken + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.plex.getToken("", "Postman"); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/updater/check"]["put"] + update: + x-codeSamples: + - lang: typescript + label: checkForUpdates + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { Download } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.updater.checkForUpdates(Download.One); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/butler/{taskName}"]["delete"] + update: + x-codeSamples: + - lang: typescript + label: stopTask + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { PathParamTaskName } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.butler.stopTask(PathParamTaskName.BackupDatabase); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/playlists/{playlistID}/items"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getPlaylistContents + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.playlists.getPlaylistContents(5004.46, 9403.59); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/photo/:/transcode"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getResizedPhoto + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { MinSize, Upscale } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.server.getResizedPhoto({ + width: 110, + height: 165, + opacity: 100, + blur: 20, + minSize: MinSize.One, + upscale: Upscale.Zero, + url: "/library/metadata/49564/thumb/1654258204", + }); // Handle the result console.log(result) @@ -244,11 +242,11 @@ actions: } run(); - - target: $["paths"]["/playlists/{playlistID}"]["delete"] + - target: $["paths"]["/status/sessions/history/all"]["get"] update: x-codeSamples: - lang: typescript - label: deletePlaylist + label: getSessionHistory source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -258,20 +256,21 @@ actions: }); async function run() { - const result = await plexAPI.playlists.deletePlaylist(216.22); + const result = await plexAPI.sessions.getSessionHistory(); // Handle the result console.log(result) } run(); - - target: $["paths"]["/security/resources"]["get"] + - target: $["paths"]["/playlists/upload"]["post"] update: x-codeSamples: - lang: typescript - label: getSourceConnectionInformation + label: uploadPlaylist source: |- import { PlexAPI } from "@lukehagar/plexjs"; + import { Force } from "@lukehagar/plexjs/models/operations"; const plexAPI = new PlexAPI({ accessToken: "", @@ -279,324 +278,7 @@ actions: }); async function run() { - const result = await plexAPI.authentication.getSourceConnectionInformation("server://client-identifier"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/clients"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getAvailableClients - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.server.getAvailableClients(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/butler"]["delete"] - update: - x-codeSamples: - - lang: typescript - label: stopAllTasks - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.butler.stopAllTasks(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/metadata/{ratingKey}"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getMetadata - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.getMetadata(8382.31); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getMetadataChildren - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.getMetadataChildren(1539.14); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/activities/{activityUUID}"]["delete"] - update: - x-codeSamples: - - lang: typescript - label: cancelServerActivities - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.activities.cancelServerActivities("25b71ed5-0f9d-461c-baa7-d404e9e10d3e"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/sections/{sectionId}/search"]["get"] - update: - x-codeSamples: - - lang: typescript - label: searchLibrary - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { Type } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.searchLibrary(933505, Type.Four); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/pins"]["post"] - update: - x-codeSamples: - - lang: typescript - label: getPin - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.plex.getPin(false, "Postman"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/pins/{pinID}"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getToken - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.plex.getToken("", "Postman"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/:/progress"]["post"] - update: - x-codeSamples: - - lang: typescript - label: updatePlayProgress - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.media.updatePlayProgress("", 90000, "played"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/butler/{taskName}"]["delete"] - update: - x-codeSamples: - - lang: typescript - label: stopTask - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { PathParamTaskName } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.butler.stopTask(PathParamTaskName.BackupDatabase); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/sections/{sectionId}"]["delete"] - update: - x-codeSamples: - - lang: typescript - label: deleteLibrary - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.deleteLibrary(1000); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/log"]["get"] - update: - x-codeSamples: - - lang: typescript - label: logLine - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { Level } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.log.logLine(Level.Three, "Test log message", "Postman"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/statistics/media"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getStatistics - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.statistics.getStatistics(4); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/devices"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getDevices - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.server.getDevices(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/hubs"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getGlobalHubs - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { OnlyTransient } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.hubs.getGlobalHubs(1262.49, OnlyTransient.One); + const result = await plexAPI.playlists.uploadPlaylist("/home/barkley/playlist.m3u", Force.Zero); // Handle the result console.log(result) @@ -646,11 +328,11 @@ actions: } run(); - - target: $["paths"]["/status/sessions"]["get"] + - target: $["paths"]["/:/unscrobble"]["get"] update: x-codeSamples: - lang: typescript - label: getSessions + label: markUnplayed source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -660,18 +342,18 @@ actions: }); async function run() { - const result = await plexAPI.sessions.getSessions(); + const result = await plexAPI.media.markUnplayed(59398); // Handle the result console.log(result) } run(); - - target: $["paths"]["/transcode/sessions"]["get"] + - target: $["paths"]["/butler"]["get"] update: x-codeSamples: - lang: typescript - label: getTranscodeSessions + label: getButlerTasks source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -681,114 +363,7 @@ actions: }); async function run() { - const result = await plexAPI.sessions.getTranscodeSessions(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"] - update: - x-codeSamples: - - lang: typescript - label: stopTranscodeSession - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.sessions.stopTranscodeSession("zz7llzqlx8w9vnrsbnwhbmep"); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/updater/status"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getUpdateStatus - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.updater.getUpdateStatus(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/updater/check"]["put"] - update: - x-codeSamples: - - lang: typescript - label: checkForUpdates - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { Download } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.updater.checkForUpdates(Download.One); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/myplex/account"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getMyPlexAccount - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.server.getMyPlexAccount(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/butler/{taskName}"]["post"] - update: - x-codeSamples: - - lang: typescript - label: startTask - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { TaskName } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.butler.startTask(TaskName.CleanOldBundles); + const result = await plexAPI.butler.getButlerTasks(); // Handle the result console.log(result) @@ -817,11 +392,11 @@ actions: } run(); - - target: $["paths"]["/status/sessions/history/all"]["get"] + - target: $["paths"]["/library/recentlyAdded"]["get"] update: x-codeSamples: - lang: typescript - label: getSessionHistory + label: getRecentlyAdded source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -831,18 +406,18 @@ actions: }); async function run() { - const result = await plexAPI.sessions.getSessionHistory(); + const result = await plexAPI.library.getRecentlyAdded(); // Handle the result console.log(result) } run(); - - target: $["paths"]["/"]["get"] + - target: $["paths"]["/library/sections/{sectionId}"]["delete"] update: x-codeSamples: - lang: typescript - label: getServerCapabilities + label: deleteLibrary source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -852,49 +427,7 @@ actions: }); async function run() { - const result = await plexAPI.server.getServerCapabilities(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/identity"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getServerIdentity - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.server.getServerIdentity(); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/:/scrobble"]["get"] - update: - x-codeSamples: - - lang: typescript - label: markPlayed - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.media.markPlayed(59398); + const result = await plexAPI.library.deleteLibrary(1000); // Handle the result console.log(result) @@ -921,6 +454,219 @@ actions: console.log(result) } + run(); + - target: $["paths"]["/playlists/{playlistID}/items"]["delete"] + update: + x-codeSamples: + - lang: typescript + label: clearPlaylistContents + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.playlists.clearPlaylistContents(1893.18); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/security/resources"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getSourceConnectionInformation + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.authentication.getSourceConnectionInformation("server://client-identifier"); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/:/scrobble"]["get"] + update: + x-codeSamples: + - lang: typescript + label: markPlayed + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.media.markPlayed(59398); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/activities"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getServerActivities + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.activities.getServerActivities(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/activities/{activityUUID}"]["delete"] + update: + x-codeSamples: + - lang: typescript + label: cancelServerActivities + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.activities.cancelServerActivities("25b71ed5-0f9d-461c-baa7-d404e9e10d3e"); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/butler/{taskName}"]["post"] + update: + x-codeSamples: + - lang: typescript + label: startTask + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { TaskName } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.butler.startTask(TaskName.CleanOldBundles); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/log"]["get"] + update: + x-codeSamples: + - lang: typescript + label: logLine + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { Level } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.log.logLine(Level.Three, "Test log message", "Postman"); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/playlists"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getPlaylists + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { PlaylistType, QueryParamSmart } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.playlists.getPlaylists(PlaylistType.Audio, QueryParamSmart.Zero); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/status/sessions"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getSessions + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.sessions.getSessions(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/:/prefs"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getServerPreferences + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.server.getServerPreferences(); + + // Handle the result + console.log(result) + } + run(); - target: $["paths"]["/servers"]["get"] update: @@ -943,13 +689,14 @@ actions: } run(); - - target: $["paths"]["/playlists/{playlistID}/items"]["get"] + - target: $["paths"]["/library/sections/{sectionId}"]["get"] update: x-codeSamples: - lang: typescript - label: getPlaylistContents + label: getLibrary source: |- import { PlexAPI } from "@lukehagar/plexjs"; + import { IncludeDetails } from "@lukehagar/plexjs/models/operations"; const plexAPI = new PlexAPI({ accessToken: "", @@ -957,18 +704,18 @@ actions: }); async function run() { - const result = await plexAPI.playlists.getPlaylistContents(5004.46, 9403.59); + const result = await plexAPI.library.getLibrary(1000, IncludeDetails.Zero); // Handle the result console.log(result) } run(); - - target: $["paths"]["/playlists/{playlistID}/items"]["delete"] + - target: $["paths"]["/transcode/sessions"]["get"] update: x-codeSamples: - lang: typescript - label: clearPlaylistContents + label: getTranscodeSessions source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -978,7 +725,87 @@ actions: }); async function run() { - const result = await plexAPI.playlists.clearPlaylistContents(1893.18); + const result = await plexAPI.sessions.getTranscodeSessions(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/myplex/account"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getMyPlexAccount + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.server.getMyPlexAccount(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"] + update: + x-codeSamples: + - lang: typescript + label: startUniversalTranscode + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.video.startUniversalTranscode({ + hasMDE: 1, + path: "/library/metadata/23409", + mediaIndex: 0, + partIndex: 0, + protocol: "hls", + fastSeek: 0, + directPlay: 0, + directStream: 0, + subtitleSize: 100, + subtites: "burn", + audioBoost: 100, + location: "lan", + mediaBufferSize: 102400, + session: "zvcage8b7rkioqcm8f4uns4c", + addDebugOverlay: 0, + autoAdjustQuality: 0, + }); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/hubs/search/voice"]["get"] + update: + x-codeSamples: + - lang: typescript + label: performVoiceSearch + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.search.performVoiceSearch("dead+poop", 4094.8, 5); // Handle the result console.log(result) @@ -1006,14 +833,13 @@ actions: } run(); - - target: $["paths"]["/playlists/upload"]["post"] + - target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"] update: x-codeSamples: - lang: typescript - label: uploadPlaylist + label: refreshLibrary source: |- import { PlexAPI } from "@lukehagar/plexjs"; - import { Force } from "@lukehagar/plexjs/models/operations"; const plexAPI = new PlexAPI({ accessToken: "", @@ -1021,7 +847,90 @@ actions: }); async function run() { - const result = await plexAPI.playlists.uploadPlaylist("/home/barkley/playlist.m3u", Force.Zero); + const result = await plexAPI.library.refreshLibrary(934.16); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getServerCapabilities + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.server.getServerCapabilities(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/library/hashes"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getFileHash + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.library.getFileHash("file://C:\Image.png&type=13", 4462.17); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/pins"]["post"] + update: + x-codeSamples: + - lang: typescript + label: getPin + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.plex.getPin(false, "Postman"); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/butler"]["post"] + update: + x-codeSamples: + - lang: typescript + label: startAllTasks + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.butler.startAllTasks(); // Handle the result console.log(result) @@ -1051,11 +960,11 @@ actions: } run(); - - target: $["paths"]["/hubs/search"]["get"] + - target: $["paths"]["/clients"]["get"] update: x-codeSamples: - lang: typescript - label: performSearch + label: getAvailableClients source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -1065,18 +974,18 @@ actions: }); async function run() { - const result = await plexAPI.search.performSearch("dylan", 1516.53, 5); + const result = await plexAPI.server.getAvailableClients(); // Handle the result console.log(result) } run(); - - target: $["paths"]["/hubs/search/voice"]["get"] + - target: $["paths"]["/butler"]["delete"] update: x-codeSamples: - lang: typescript - label: performVoiceSearch + label: stopAllTasks source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -1086,50 +995,7 @@ actions: }); async function run() { - const result = await plexAPI.search.performVoiceSearch("dead+poop", 4094.8, 5); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/sections/{sectionId}/{tag}"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getLibraryItems - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { Tag } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.getLibraryItems(1, Tag.Genre); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"] - update: - x-codeSamples: - - lang: typescript - label: refreshLibrary - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.library.refreshLibrary(934.16); + const result = await plexAPI.butler.stopAllTasks(); // Handle the result console.log(result) @@ -1157,38 +1023,11 @@ actions: } run(); - - target: $["paths"]["/playlists"]["post"] + - target: $["paths"]["/updater/status"]["get"] update: x-codeSamples: - lang: typescript - label: createPlaylist - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { QueryParamType, Smart } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.playlists.createPlaylist({ - title: "", - type: QueryParamType.Photo, - smart: Smart.One, - uri: "https://inborn-brochure.biz", - }); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/playlists/{playlistID}/items"]["put"] - update: - x-codeSamples: - - lang: typescript - label: addPlaylistContents + label: getUpdateStatus source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -1198,7 +1037,7 @@ actions: }); async function run() { - const result = await plexAPI.playlists.addPlaylistContents(8502.01, "server://12345/com.plexapp.plugins.library/library/metadata/1", 123); + const result = await plexAPI.updater.getUpdateStatus(); // Handle the result console.log(result) @@ -1227,41 +1066,11 @@ actions: } run(); - - target: $["paths"]["/photo/:/transcode"]["get"] + - target: $["paths"]["/devices"]["get"] update: x-codeSamples: - lang: typescript - label: getResizedPhoto - source: |- - import { PlexAPI } from "@lukehagar/plexjs"; - import { MinSize, Upscale } from "@lukehagar/plexjs/models/operations"; - - const plexAPI = new PlexAPI({ - accessToken: "", - xPlexClientIdentifier: "Postman", - }); - - async function run() { - const result = await plexAPI.server.getResizedPhoto({ - width: 110, - height: 165, - opacity: 100, - blur: 20, - minSize: MinSize.One, - upscale: Upscale.Zero, - url: "/library/metadata/49564/thumb/1654258204", - }); - - // Handle the result - console.log(result) - } - - run(); - - target: $["paths"]["/activities"]["get"] - update: - x-codeSamples: - - lang: typescript - label: getServerActivities + label: getDevices source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -1271,18 +1080,40 @@ actions: }); async function run() { - const result = await plexAPI.activities.getServerActivities(); + const result = await plexAPI.server.getDevices(); // Handle the result console.log(result) } run(); - - target: $["paths"]["/butler"]["post"] + - target: $["paths"]["/hubs"]["get"] update: x-codeSamples: - lang: typescript - label: startAllTasks + label: getGlobalHubs + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { OnlyTransient } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.hubs.getGlobalHubs(1262.49, OnlyTransient.One); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/playlists/{playlistID}"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getPlaylist source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -1292,18 +1123,18 @@ actions: }); async function run() { - const result = await plexAPI.butler.startAllTasks(); + const result = await plexAPI.playlists.getPlaylist(4109.48); // Handle the result console.log(result) } run(); - - target: $["paths"]["/library/hashes"]["get"] + - target: $["paths"]["/:/progress"]["post"] update: x-codeSamples: - lang: typescript - label: getFileHash + label: updatePlayProgress source: |- import { PlexAPI } from "@lukehagar/plexjs"; @@ -1313,7 +1144,176 @@ actions: }); async function run() { - const result = await plexAPI.library.getFileHash("file://C:\Image.png&type=13", 4462.17); + const result = await plexAPI.media.updatePlayProgress("", 90000, "played"); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/hubs/search"]["get"] + update: + x-codeSamples: + - lang: typescript + label: performSearch + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.search.performSearch("dylan", 1516.53, 5); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/library/sections"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getLibraries + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.library.getLibraries(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/library/sections/{sectionId}/search"]["get"] + update: + x-codeSamples: + - lang: typescript + label: searchLibrary + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + import { Type } from "@lukehagar/plexjs/models/operations"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.library.searchLibrary(933505, Type.Four); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/identity"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getServerIdentity + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.server.getServerIdentity(); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/statistics/media"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getStatistics + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.statistics.getStatistics(4); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"] + update: + x-codeSamples: + - lang: typescript + label: getMetadataChildren + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.library.getMetadataChildren(1539.14); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/playlists/{playlistID}/items"]["put"] + update: + x-codeSamples: + - lang: typescript + label: addPlaylistContents + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.playlists.addPlaylistContents(8502.01, "server://12345/com.plexapp.plugins.library/library/metadata/1", 123); + + // Handle the result + console.log(result) + } + + run(); + - target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"] + update: + x-codeSamples: + - lang: typescript + label: stopTranscodeSession + source: |- + import { PlexAPI } from "@lukehagar/plexjs"; + + const plexAPI = new PlexAPI({ + accessToken: "", + xPlexClientIdentifier: "Postman", + }); + + async function run() { + const result = await plexAPI.sessions.stopTranscodeSession("zz7llzqlx8w9vnrsbnwhbmep"); // Handle the result console.log(result) diff --git a/jsr.json b/jsr.json index 37746ca3..71028acd 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@lukehagar/plexjs", - "version": "0.16.4", + "version": "0.16.5", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index b33613c8..4494639a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lukehagar/plexjs", - "version": "0.16.4", + "version": "0.16.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lukehagar/plexjs", - "version": "0.16.4", + "version": "0.16.5", "devDependencies": { "@types/jsonpath": "^0.2.4", "@typescript-eslint/eslint-plugin": "^7.7.1", diff --git a/package.json b/package.json index a01963b7..aafa46e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lukehagar/plexjs", - "version": "0.16.4", + "version": "0.16.5", "author": "LukeHagar", "main": "./index.js", "sideEffects": false, diff --git a/src/lib/config.ts b/src/lib/config.ts index 757998af..5fd1f3ab 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -87,7 +87,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.3", - sdkVersion: "0.16.4", - genVersion: "2.338.14", - userAgent: "speakeasy-sdk/typescript 0.16.4 2.338.14 0.0.3 @lukehagar/plexjs", + sdkVersion: "0.16.5", + genVersion: "2.340.3", + userAgent: "speakeasy-sdk/typescript 0.16.5 2.340.3 0.0.3 @lukehagar/plexjs", } as const; diff --git a/src/lib/encodings.ts b/src/lib/encodings.ts index 8cd50f68..c28d8944 100644 --- a/src/lib/encodings.ts +++ b/src/lib/encodings.ts @@ -383,3 +383,49 @@ function mapDefinedEntries( return acc; } + +export function queryJoin(...args: string[]): string { + return args.filter(Boolean).join("&"); +} + +type QueryEncoderOptions = { + explode?: boolean; + charEncoding?: "percent" | "none"; +}; + +type QueryEncoder = ( + key: string, + value: unknown, + options?: QueryEncoderOptions, +) => string; + +type BulkQueryEncoder = ( + values: Record, + options?: QueryEncoderOptions, +) => string; + +export function queryEncoder(f: QueryEncoder): BulkQueryEncoder { + const bulkEncode = function ( + values: Record, + options?: QueryEncoderOptions, + ): string { + const opts: QueryEncoderOptions = { + ...options, + explode: options?.explode ?? true, + charEncoding: options?.charEncoding ?? "percent", + }; + + const encoded = Object.entries(values).map(([key, value]) => { + return f(key, value, opts); + }); + return queryJoin(...encoded); + }; + + return bulkEncode; +} + +export const encodeJSONQuery = queryEncoder(encodeJSON); +export const encodeFormQuery = queryEncoder(encodeForm); +export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited); +export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited); +export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject); diff --git a/src/sdk/activities.ts b/src/sdk/activities.ts index 7f918548..c8b8e6b2 100644 --- a/src/sdk/activities.ts +++ b/src/sdk/activities.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -126,7 +126,7 @@ export class Activities extends ClientSDK { const body$ = null; const pathParams$ = { - activityUUID: enc$.encodeSimple("activityUUID", payload$.activityUUID, { + activityUUID: encodeSimple$("activityUUID", payload$.activityUUID, { explode: false, charEncoding: "percent", }), diff --git a/src/sdk/authentication.ts b/src/sdk/authentication.ts index 1ccac20b..30cf8f4a 100644 --- a/src/sdk/authentication.ts +++ b/src/sdk/authentication.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -67,12 +67,10 @@ export class Authentication extends ClientSDK { const path$ = this.templateURLComponent("/security/token")(); - const query$ = [ - enc$.encodeForm("scope", payload$.scope, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("type", payload$.type, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + type: payload$.type, + scope: payload$.scope, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -150,11 +148,9 @@ export class Authentication extends ClientSDK { const path$ = this.templateURLComponent("/security/resources")(); - const query$ = [ - enc$.encodeForm("source", payload$.source, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + source: payload$.source, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/butler.ts b/src/sdk/butler.ts index e77bd8e6..2d662f2d 100644 --- a/src/sdk/butler.ts +++ b/src/sdk/butler.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -257,7 +257,7 @@ export class Butler extends ClientSDK { const body$ = null; const pathParams$ = { - taskName: enc$.encodeSimple("taskName", payload$.taskName, { + taskName: encodeSimple$("taskName", payload$.taskName, { explode: false, charEncoding: "percent", }), @@ -339,7 +339,7 @@ export class Butler extends ClientSDK { const body$ = null; const pathParams$ = { - taskName: enc$.encodeSimple("taskName", payload$.taskName, { + taskName: encodeSimple$("taskName", payload$.taskName, { explode: false, charEncoding: "percent", }), diff --git a/src/sdk/hubs.ts b/src/sdk/hubs.ts index 90230bd7..9c1b5f9b 100644 --- a/src/sdk/hubs.ts +++ b/src/sdk/hubs.ts @@ -4,7 +4,10 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { + encodeFormQuery as encodeFormQuery$, + encodeSimple as encodeSimple$, +} from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -66,15 +69,10 @@ export class Hubs extends ClientSDK { const path$ = this.templateURLComponent("/hubs")(); - const query$ = [ - enc$.encodeForm("count", payload$.count, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("onlyTransient", payload$.onlyTransient, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + count: payload$.count, + onlyTransient: payload$.onlyTransient, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -153,22 +151,17 @@ export class Hubs extends ClientSDK { const body$ = null; const pathParams$ = { - sectionId: enc$.encodeSimple("sectionId", payload$.sectionId, { + sectionId: encodeSimple$("sectionId", payload$.sectionId, { explode: false, charEncoding: "percent", }), }; const path$ = this.templateURLComponent("/hubs/sections/{sectionId}")(pathParams$); - const query$ = [ - enc$.encodeForm("count", payload$.count, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("onlyTransient", payload$.onlyTransient, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + count: payload$.count, + onlyTransient: payload$.onlyTransient, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/library.ts b/src/sdk/library.ts index 04eac49a..79414ff8 100644 --- a/src/sdk/library.ts +++ b/src/sdk/library.ts @@ -4,7 +4,10 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { + encodeFormQuery as encodeFormQuery$, + encodeSimple as encodeSimple$, +} from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -66,12 +69,10 @@ export class Library extends ClientSDK { const path$ = this.templateURLComponent("/library/hashes")(); - const query$ = [ - enc$.encodeForm("type", payload$.type, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("url", payload$.url, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + url: payload$.url, + type: payload$.type, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -315,21 +316,16 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - sectionId: enc$.encodeSimple("sectionId", payload$.sectionId, { + sectionId: encodeSimple$("sectionId", payload$.sectionId, { explode: false, charEncoding: "percent", }), }; const path$ = this.templateURLComponent("/library/sections/{sectionId}")(pathParams$); - const query$ = [ - enc$.encodeForm("includeDetails", payload$.includeDetails, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + includeDetails: payload$.includeDetails, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -403,7 +399,7 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - sectionId: enc$.encodeSimple("sectionId", payload$.sectionId, { + sectionId: encodeSimple$("sectionId", payload$.sectionId, { explode: false, charEncoding: "percent", }), @@ -506,14 +502,11 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - sectionId: enc$.encodeSimple("sectionId", payload$.sectionId, { - explode: false, - charEncoding: "percent", - }), - tag: enc$.encodeSimple("tag", payload$.tag, { + sectionId: encodeSimple$("sectionId", payload$.sectionId, { explode: false, charEncoding: "percent", }), + tag: encodeSimple$("tag", payload$.tag, { explode: false, charEncoding: "percent" }), }; const path$ = this.templateURLComponent("/library/sections/{sectionId}/{tag}")(pathParams$); @@ -592,7 +585,7 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - sectionId: enc$.encodeSimple("sectionId", payload$.sectionId, { + sectionId: encodeSimple$("sectionId", payload$.sectionId, { explode: false, charEncoding: "percent", }), @@ -695,7 +688,7 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - sectionId: enc$.encodeSimple("sectionId", payload$.sectionId, { + sectionId: encodeSimple$("sectionId", payload$.sectionId, { explode: false, charEncoding: "percent", }), @@ -704,11 +697,9 @@ export class Library extends ClientSDK { pathParams$ ); - const query$ = [ - enc$.encodeForm("type", payload$.type, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + type: payload$.type, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -783,7 +774,7 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - ratingKey: enc$.encodeSimple("ratingKey", payload$.ratingKey, { + ratingKey: encodeSimple$("ratingKey", payload$.ratingKey, { explode: false, charEncoding: "percent", }), @@ -865,7 +856,7 @@ export class Library extends ClientSDK { const body$ = null; const pathParams$ = { - ratingKey: enc$.encodeSimple("ratingKey", payload$.ratingKey, { + ratingKey: encodeSimple$("ratingKey", payload$.ratingKey, { explode: false, charEncoding: "percent", }), diff --git a/src/sdk/log.ts b/src/sdk/log.ts index 69ab8239..18c84a6e 100644 --- a/src/sdk/log.ts +++ b/src/sdk/log.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -70,16 +70,11 @@ export class Log extends ClientSDK { const path$ = this.templateURLComponent("/log")(); - const query$ = [ - enc$.encodeForm("level", payload$.level, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("message", payload$.message, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("source", payload$.source, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + level: payload$.level, + message: payload$.message, + source: payload$.source, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/media.ts b/src/sdk/media.ts index c863c75b..35981edc 100644 --- a/src/sdk/media.ts +++ b/src/sdk/media.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -64,11 +64,9 @@ export class Media extends ClientSDK { const path$ = this.templateURLComponent("/:/scrobble")(); - const query$ = [ - enc$.encodeForm("key", payload$.key, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + key: payload$.key, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -143,11 +141,9 @@ export class Media extends ClientSDK { const path$ = this.templateURLComponent("/:/unscrobble")(); - const query$ = [ - enc$.encodeForm("key", payload$.key, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + key: payload$.key, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -227,13 +223,11 @@ export class Media extends ClientSDK { const path$ = this.templateURLComponent("/:/progress")(); - const query$ = [ - enc$.encodeForm("key", payload$.key, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("state", payload$.state, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("time", payload$.time, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + key: payload$.key, + time: payload$.time, + state: payload$.state, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/playlists.ts b/src/sdk/playlists.ts index 5481203a..e95f32b3 100644 --- a/src/sdk/playlists.ts +++ b/src/sdk/playlists.ts @@ -4,7 +4,10 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { + encodeFormQuery as encodeFormQuery$, + encodeSimple as encodeSimple$, +} from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -65,18 +68,13 @@ export class Playlists extends ClientSDK { const path$ = this.templateURLComponent("/playlists")(); - const query$ = [ - enc$.encodeForm("playQueueID", payload$.playQueueID, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("smart", payload$.smart, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("title", payload$.title, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("type", payload$.type, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("uri", payload$.uri, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + uri: payload$.uri, + playQueueID: payload$.playQueueID, + title: payload$.title, + type: payload$.type, + smart: payload$.smart, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -153,15 +151,10 @@ export class Playlists extends ClientSDK { const path$ = this.templateURLComponent("/playlists")(); - const query$ = [ - enc$.encodeForm("playlistType", payload$.playlistType, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("smart", payload$.smart, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + smart: payload$.smart, + playlistType: payload$.playlistType, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -237,7 +230,7 @@ export class Playlists extends ClientSDK { const body$ = null; const pathParams$ = { - playlistID: enc$.encodeSimple("playlistID", payload$.playlistID, { + playlistID: encodeSimple$("playlistID", payload$.playlistID, { explode: false, charEncoding: "percent", }), @@ -319,7 +312,7 @@ export class Playlists extends ClientSDK { const body$ = null; const pathParams$ = { - playlistID: enc$.encodeSimple("playlistID", payload$.playlistID, { + playlistID: encodeSimple$("playlistID", payload$.playlistID, { explode: false, charEncoding: "percent", }), @@ -405,22 +398,17 @@ export class Playlists extends ClientSDK { const body$ = null; const pathParams$ = { - playlistID: enc$.encodeSimple("playlistID", payload$.playlistID, { + playlistID: encodeSimple$("playlistID", payload$.playlistID, { explode: false, charEncoding: "percent", }), }; const path$ = this.templateURLComponent("/playlists/{playlistID}")(pathParams$); - const query$ = [ - enc$.encodeForm("summary", payload$.summary, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("title", payload$.title, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + title: payload$.title, + summary: payload$.summary, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -500,18 +488,16 @@ export class Playlists extends ClientSDK { const body$ = null; const pathParams$ = { - playlistID: enc$.encodeSimple("playlistID", payload$.playlistID, { + playlistID: encodeSimple$("playlistID", payload$.playlistID, { explode: false, charEncoding: "percent", }), }; const path$ = this.templateURLComponent("/playlists/{playlistID}/items")(pathParams$); - const query$ = [ - enc$.encodeForm("type", payload$.type, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + type: payload$.type, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -586,7 +572,7 @@ export class Playlists extends ClientSDK { const body$ = null; const pathParams$ = { - playlistID: enc$.encodeSimple("playlistID", payload$.playlistID, { + playlistID: encodeSimple$("playlistID", payload$.playlistID, { explode: false, charEncoding: "percent", }), @@ -673,22 +659,17 @@ export class Playlists extends ClientSDK { const body$ = null; const pathParams$ = { - playlistID: enc$.encodeSimple("playlistID", payload$.playlistID, { + playlistID: encodeSimple$("playlistID", payload$.playlistID, { explode: false, charEncoding: "percent", }), }; const path$ = this.templateURLComponent("/playlists/{playlistID}/items")(pathParams$); - const query$ = [ - enc$.encodeForm("playQueueID", payload$.playQueueID, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("uri", payload$.uri, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + playQueueID: payload$.playQueueID, + uri: payload$.uri, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -766,12 +747,10 @@ export class Playlists extends ClientSDK { const path$ = this.templateURLComponent("/playlists/upload")(); - const query$ = [ - enc$.encodeForm("force", payload$.force, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("path", payload$.path, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + force: payload$.force, + path: payload$.path, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/plex.ts b/src/sdk/plex.ts index 37d8964a..52e68e4e 100644 --- a/src/sdk/plex.ts +++ b/src/sdk/plex.ts @@ -4,7 +4,10 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { + encodeFormQuery as encodeFormQuery$, + encodeSimple as encodeSimple$, +} from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -71,15 +74,13 @@ export class Plex extends ClientSDK { const path$ = this.templateURLComponent("/pins")(); - const query$ = [ - enc$.encodeForm("strong", payload$.strong, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + strong: payload$.strong, + }); headers$.set( "X-Plex-Client-Identifier", - enc$.encodeSimple( + encodeSimple$( "X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"] ?? this.options$.xPlexClientIdentifier, { explode: false, charEncoding: "none" } @@ -151,7 +152,7 @@ export class Plex extends ClientSDK { })(); const pathParams$ = { - pinID: enc$.encodeSimple("pinID", payload$.pinID, { + pinID: encodeSimple$("pinID", payload$.pinID, { explode: false, charEncoding: "percent", }), @@ -162,7 +163,7 @@ export class Plex extends ClientSDK { headers$.set( "X-Plex-Client-Identifier", - enc$.encodeSimple( + encodeSimple$( "X-Plex-Client-Identifier", payload$["X-Plex-Client-Identifier"] ?? this.options$.xPlexClientIdentifier, { explode: false, charEncoding: "none" } diff --git a/src/sdk/search.ts b/src/sdk/search.ts index 6cde58ba..0caff953 100644 --- a/src/sdk/search.ts +++ b/src/sdk/search.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -80,16 +80,11 @@ export class Search extends ClientSDK { const path$ = this.templateURLComponent("/hubs/search")(); - const query$ = [ - enc$.encodeForm("limit", payload$.limit, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("query", payload$.query, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("sectionId", payload$.sectionId, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + query: payload$.query, + sectionId: payload$.sectionId, + limit: payload$.limit, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -172,16 +167,11 @@ export class Search extends ClientSDK { const path$ = this.templateURLComponent("/hubs/search/voice")(); - const query$ = [ - enc$.encodeForm("limit", payload$.limit, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("query", payload$.query, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("sectionId", payload$.sectionId, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + query: payload$.query, + sectionId: payload$.sectionId, + limit: payload$.limit, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -256,11 +246,9 @@ export class Search extends ClientSDK { const path$ = this.templateURLComponent("/search")(); - const query$ = [ - enc$.encodeForm("query", payload$.query, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + query: payload$.query, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/server.ts b/src/sdk/server.ts index d9758c22..69b7a1c2 100644 --- a/src/sdk/server.ts +++ b/src/sdk/server.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -437,26 +437,15 @@ export class Server extends ClientSDK { const path$ = this.templateURLComponent("/photo/:/transcode")(); - const query$ = [ - enc$.encodeForm("blur", payload$.blur, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("height", payload$.height, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("minSize", payload$.minSize, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("opacity", payload$.opacity, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("upscale", payload$.upscale, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("url", payload$.url, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("width", payload$.width, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + url: payload$.url, + width: payload$.width, + height: payload$.height, + opacity: payload$.opacity, + blur: payload$.blur, + minSize: payload$.minSize, + upscale: payload$.upscale, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/sessions.ts b/src/sdk/sessions.ts index 5aeb0fc8..591edc52 100644 --- a/src/sdk/sessions.ts +++ b/src/sdk/sessions.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeSimple as encodeSimple$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -250,7 +250,7 @@ export class Sessions extends ClientSDK { const body$ = null; const pathParams$ = { - sessionKey: enc$.encodeSimple("sessionKey", payload$.sessionKey, { + sessionKey: encodeSimple$("sessionKey", payload$.sessionKey, { explode: false, charEncoding: "percent", }), diff --git a/src/sdk/statistics.ts b/src/sdk/statistics.ts index 30e1f549..1229cb5b 100644 --- a/src/sdk/statistics.ts +++ b/src/sdk/statistics.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -64,14 +64,9 @@ export class Statistics extends ClientSDK { const path$ = this.templateURLComponent("/statistics/media")(); - const query$ = [ - enc$.encodeForm("Timespan", payload$.Timespan, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + Timespan: payload$.Timespan, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/updater.ts b/src/sdk/updater.ts index cf2cee65..3d7ad8d8 100644 --- a/src/sdk/updater.ts +++ b/src/sdk/updater.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -125,14 +125,9 @@ export class Updater extends ClientSDK { const path$ = this.templateURLComponent("/updater/check")(); - const query$ = [ - enc$.encodeForm("download", payload$.download, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + download: payload$.download, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -210,15 +205,10 @@ export class Updater extends ClientSDK { const path$ = this.templateURLComponent("/updater/apply")(); - const query$ = [ - enc$.encodeForm("skip", payload$.skip, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("tonight", payload$.tonight, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + tonight: payload$.tonight, + skip: payload$.skip, + }); let security$; if (typeof this.options$.accessToken === "function") { diff --git a/src/sdk/video.ts b/src/sdk/video.ts index e2853da4..38e2d659 100644 --- a/src/sdk/video.ts +++ b/src/sdk/video.ts @@ -4,7 +4,7 @@ import { SDKHooks } from "../hooks"; import { SDK_METADATA, SDKOptions, serverURLFromOptions } from "../lib/config"; -import * as enc$ from "../lib/encodings"; +import { encodeFormQuery as encodeFormQuery$ } from "../lib/encodings"; import { HTTPClient } from "../lib/http"; import * as schemas$ from "../lib/schemas"; import { ClientSDK, RequestOptions } from "../lib/sdks"; @@ -62,35 +62,18 @@ export class Video extends ClientSDK { const path$ = this.templateURLComponent("/:/timeline")(); - const query$ = [ - enc$.encodeForm("context", payload$.context, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("duration", payload$.duration, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("hasMDE", payload$.hasMDE, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("key", payload$.key, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("playBackTime", payload$.playBackTime, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("playQueueItemID", payload$.playQueueItemID, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("ratingKey", payload$.ratingKey, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("row", payload$.row, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("state", payload$.state, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("time", payload$.time, { explode: true, charEncoding: "percent" }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + ratingKey: payload$.ratingKey, + hasMDE: payload$.hasMDE, + time: payload$.time, + playBackTime: payload$.playBackTime, + playQueueItemID: payload$.playQueueItemID, + row: payload$.row, + key: payload$.key, + state: payload$.state, + duration: payload$.duration, + context: payload$.context, + }); let security$; if (typeof this.options$.accessToken === "function") { @@ -163,68 +146,24 @@ export class Video extends ClientSDK { const path$ = this.templateURLComponent("/video/:/transcode/universal/start.mpd")(); - const query$ = [ - enc$.encodeForm("addDebugOverlay", payload$.addDebugOverlay, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("audioBoost", payload$.audioBoost, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("autoAdjustQuality", payload$.autoAdjustQuality, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("directPlay", payload$.directPlay, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("directStream", payload$.directStream, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("fastSeek", payload$.fastSeek, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("hasMDE", payload$.hasMDE, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("location", payload$.location, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("mediaBufferSize", payload$.mediaBufferSize, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("mediaIndex", payload$.mediaIndex, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("partIndex", payload$.partIndex, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("path", payload$.path, { explode: true, charEncoding: "percent" }), - enc$.encodeForm("protocol", payload$.protocol, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("session", payload$.session, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("subtites", payload$.subtites, { - explode: true, - charEncoding: "percent", - }), - enc$.encodeForm("subtitleSize", payload$.subtitleSize, { - explode: true, - charEncoding: "percent", - }), - ] - .filter(Boolean) - .join("&"); + const query$ = encodeFormQuery$({ + path: payload$.path, + directStream: payload$.directStream, + audioBoost: payload$.audioBoost, + location: payload$.location, + mediaBufferSize: payload$.mediaBufferSize, + addDebugOverlay: payload$.addDebugOverlay, + partIndex: payload$.partIndex, + fastSeek: payload$.fastSeek, + subtitleSize: payload$.subtitleSize, + session: payload$.session, + mediaIndex: payload$.mediaIndex, + autoAdjustQuality: payload$.autoAdjustQuality, + hasMDE: payload$.hasMDE, + protocol: payload$.protocol, + directPlay: payload$.directPlay, + subtites: payload$.subtites, + }); let security$; if (typeof this.options$.accessToken === "function") {