mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 12:37:46 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbe2e37bba |
@@ -3,10 +3,10 @@ id: 16f22cbf-f23f-4419-8924-3a4b06381947
|
||||
management:
|
||||
docChecksum: e34dac84738ebf2d447ea2b9055a6eeb
|
||||
docVersion: 0.0.3
|
||||
speakeasyVersion: 1.213.0
|
||||
generationVersion: 2.283.1
|
||||
releaseVersion: 0.10.4
|
||||
configChecksum: 79121d7caddd1a69343bca5df91689af
|
||||
speakeasyVersion: 1.227.0
|
||||
generationVersion: 2.291.0
|
||||
releaseVersion: 0.11.0
|
||||
configChecksum: 8ed91aa4573f3ab00f3d32ae29436c8f
|
||||
repoURL: https://github.com/LukeHagar/plexjs.git
|
||||
repoSubDirectory: .
|
||||
installationURL: https://github.com/LukeHagar/plexjs
|
||||
@@ -14,7 +14,7 @@ management:
|
||||
features:
|
||||
typescript:
|
||||
constsAndDefaults: 0.1.5
|
||||
core: 3.6.3
|
||||
core: 3.7.0
|
||||
flattening: 2.81.1
|
||||
globalSecurity: 2.82.8
|
||||
globalServerURLs: 2.82.4
|
||||
|
||||
12
RELEASES.md
12
RELEASES.md
@@ -268,4 +268,14 @@ Based on:
|
||||
### Generated
|
||||
- [typescript v0.10.4] .
|
||||
### Releases
|
||||
- [NPM v0.10.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.4 - .
|
||||
- [NPM v0.10.4] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.10.4 - .
|
||||
|
||||
## 2024-03-27 00:25:29
|
||||
### Changes
|
||||
Based on:
|
||||
- OpenAPI Doc
|
||||
- Speakeasy CLI 1.227.0 (2.291.0) https://github.com/speakeasy-api/speakeasy
|
||||
### Generated
|
||||
- [typescript v0.11.0] .
|
||||
### Releases
|
||||
- [NPM v0.11.0] https://www.npmjs.com/package/@lukehagar/plexjs/v/0.11.0 - .
|
||||
2
gen.yaml
2
gen.yaml
@@ -12,7 +12,7 @@ generation:
|
||||
auth:
|
||||
oAuth2ClientCredentialsEnabled: false
|
||||
typescript:
|
||||
version: 0.10.4
|
||||
version: 0.11.0
|
||||
additionalDependencies:
|
||||
dependencies: {}
|
||||
devDependencies: {}
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.10.4",
|
||||
"version": "0.11.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.10.4",
|
||||
"version": "0.11.0",
|
||||
"devDependencies": {
|
||||
"@types/jsonpath": "^0.2.4",
|
||||
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@lukehagar/plexjs",
|
||||
"version": "0.10.4",
|
||||
"version": "0.11.0",
|
||||
"author": "LukeHagar",
|
||||
"main": "./index.js",
|
||||
"sideEffects": false,
|
||||
|
||||
@@ -82,7 +82,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
||||
export const SDK_METADATA = Object.freeze({
|
||||
language: "typescript",
|
||||
openapiDocVersion: "0.0.3",
|
||||
sdkVersion: "0.10.4",
|
||||
genVersion: "2.283.1",
|
||||
userAgent: "speakeasy-sdk/typescript 0.10.4 2.283.1 0.0.3 @lukehagar/plexjs",
|
||||
sdkVersion: "0.11.0",
|
||||
genVersion: "2.291.0",
|
||||
userAgent: "speakeasy-sdk/typescript 0.11.0 2.291.0 0.0.3 @lukehagar/plexjs",
|
||||
});
|
||||
|
||||
@@ -7,15 +7,17 @@ export type Fetcher = (
|
||||
init?: RequestInit,
|
||||
) => Promise<Response>;
|
||||
|
||||
type Awaitable<T> = T | Promise<T>;
|
||||
|
||||
const DEFAULT_FETCHER: Fetcher = (input, init) => fetch(input, init);
|
||||
|
||||
export interface HTTPClientOptions {
|
||||
fetcher?: Fetcher;
|
||||
}
|
||||
|
||||
type BeforeRequestHook = (req: Request) => Request | void;
|
||||
type RequestErrorHook = (err: unknown, req: Request) => void;
|
||||
type ResponseHook = (res: Response, req: Request) => void;
|
||||
type BeforeRequestHook = (req: Request) => Awaitable<Request | void>;
|
||||
type RequestErrorHook = (err: unknown, req: Request) => Awaitable<void>;
|
||||
type ResponseHook = (res: Response, req: Request) => Awaitable<void>;
|
||||
|
||||
export class HTTPClient {
|
||||
private fetcher: Fetcher;
|
||||
@@ -28,17 +30,27 @@ export class HTTPClient {
|
||||
}
|
||||
|
||||
async request(request: Request): Promise<Response> {
|
||||
const req = this.requestHooks.reduce((currentReq, fn) => {
|
||||
const nextRequest = fn(currentReq);
|
||||
return nextRequest || currentReq;
|
||||
}, request);
|
||||
let req = request;
|
||||
for (const hook of this.requestHooks) {
|
||||
const nextRequest = await hook(req);
|
||||
if (nextRequest) {
|
||||
req = nextRequest;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await this.fetcher(req);
|
||||
this.responseHooks.forEach((fn) => fn(res, req));
|
||||
|
||||
for (const hook of this.responseHooks) {
|
||||
await hook(res, req);
|
||||
}
|
||||
|
||||
return res;
|
||||
} catch (err) {
|
||||
this.requestErrorHooks.forEach((fn) => fn(err, req));
|
||||
for (const hook of this.requestErrorHooks) {
|
||||
await hook(err, req);
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user