diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 93324ce..330e6cc 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: ede0e8e6-5a63-4cc3-bd29-551cf1036a60 management: - docChecksum: 60d27c46481b9d9f9618b01182214273 + docChecksum: 507ce959f2b1b52532ffcbaef25cbd3c docVersion: 4.0.0 - speakeasyVersion: 1.454.0 - generationVersion: 2.477.0 - releaseVersion: 5.2.0-alpha.3 - configChecksum: 2ca1feb8f638dc37fe2c80ab026067e7 + speakeasyVersion: 1.455.7 + generationVersion: 2.480.1 + releaseVersion: 5.2.0-alpha.4 + configChecksum: 1773e82e2fde2ac70734438bf70aebcd repoURL: https://github.com/ryan-timothy-albert/simple-ts-sdk.git installationURL: https://github.com/ryan-timothy-albert/simple-ts-sdk published: true @@ -14,7 +14,7 @@ features: typescript: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.11 - core: 3.18.9 + core: 3.18.11 defaultEnabledRetries: 0.1.0 devContainers: 2.90.0 enumUnions: 0.1.0 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 2eba7c8..4fd6766 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -16,7 +16,7 @@ generation: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: false typescript: - version: 5.2.0-alpha.3 + version: 5.2.0-alpha.4 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 1f31a76..f60c012 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,28 +1,28 @@ -speakeasyVersion: 1.454.0 +speakeasyVersion: 1.455.7 sources: petstore-oas: sourceNamespace: petstore-oas - sourceRevisionDigest: sha256:2f8622bc49b53a4b02bf1d1a3fae05c7b1009f370dd340e8ec8d0244d854f300 - sourceBlobDigest: sha256:f02c4f38e98b5b0d5cbcb1cfb791c984d70a54ced9305986b23dadad78683d80 + sourceRevisionDigest: sha256:a86050db0f12fc18827e67c7dbd2527f59004ea80052d5774f8020640ac29ea3 + sourceBlobDigest: sha256:96cc6fae3e7a587d1440a68ab7d0ec805f37c12baa238e0aaefe4fd7e4e755a2 tags: - latest - - speakeasy-sdk-regen-1733934520 + - speakeasy-sdk-regen-1734377680 - 4.0.0 targets: petstore: source: petstore-oas sourceNamespace: petstore-oas - sourceRevisionDigest: sha256:2f8622bc49b53a4b02bf1d1a3fae05c7b1009f370dd340e8ec8d0244d854f300 - sourceBlobDigest: sha256:f02c4f38e98b5b0d5cbcb1cfb791c984d70a54ced9305986b23dadad78683d80 + sourceRevisionDigest: sha256:a86050db0f12fc18827e67c7dbd2527f59004ea80052d5774f8020640ac29ea3 + sourceBlobDigest: sha256:96cc6fae3e7a587d1440a68ab7d0ec805f37c12baa238e0aaefe4fd7e4e755a2 codeSamplesNamespace: petstore-oas-typescript-code-samples - codeSamplesRevisionDigest: sha256:95d9accf719cd21101e9a13d416365972e07d3db9a5f61986fe1d7f5cc419956 + codeSamplesRevisionDigest: sha256:96db5b1e15a86c97a0bc6cb251f727900d702abf838befe3a0e576571c5e75bd workflow: workflowVersion: 1.0.0 speakeasyVersion: latest sources: petstore-oas: inputs: - - location: openapi.yaml + - location: openapi.json registry: location: registry.speakeasyapi.dev/ryan-local/ryan-telemetry/petstore-oas targets: diff --git a/README.md b/README.md index 1156821..8e5333c 100644 --- a/README.md +++ b/README.md @@ -325,19 +325,7 @@ run(); ## Error Handling -All SDK methods return a response object or throw an error. By default, an API error will throw a `errors.SDKError`. - -If a HTTP request fails, an operation my also throw an error from the `models/errors/httpclienterrors.ts` module: - -| HTTP Client Error | Description | -| ---------------------------------------------------- | ---------------------------------------------------- | -| RequestAbortedError | HTTP request was aborted by the client | -| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal | -| ConnectionError | HTTP client was unable to make a request to a server | -| InvalidRequestError | Any input used to create a request is invalid | -| UnexpectedClientError | Unrecognised or unexpected error | - -In addition, when custom error responses are specified for an operation, the SDK may throw their associated Error type. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. For example, the `sit` method may throw the following errors: +Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `sit` method may throw the following errors: | Error Type | Status Code | Content Type | | --------------------------- | ----------- | ---------------- | @@ -346,6 +334,8 @@ In addition, when custom error responses are specified for an operation, the SDK | errors.ApiErrorNotFound | 404 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | +If the method throws an error and it is not captured by the known errors, it will default to throwing a `SDKError`. + ```typescript import { Petstore } from "ryan-simple-test-act"; import { @@ -379,8 +369,9 @@ async function run() { console.log(result); } catch (err) { switch (true) { + // The server response does not match the expected SDK schema case (err instanceof SDKValidationError): { - // Validation errors can be pretty-printed + // Pretty-print will provide a human-readable multi-line error message console.error(err.pretty()); // Raw value may also be inspected console.error(err.rawValue); @@ -402,6 +393,7 @@ async function run() { return; } default: { + // Other errors such as network errors, see HTTPClientErrors for more details throw err; } } @@ -412,7 +404,17 @@ run(); ``` -Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging. +Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging. + +In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module: + +| HTTP Client Error | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | +| RequestAbortedError | HTTP request was aborted by the client | +| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal | +| ConnectionError | HTTP client was unable to make a request to a server | +| InvalidRequestError | Any input used to create a request is invalid | +| UnexpectedClientError | Unrecognised or unexpected error | diff --git a/RELEASES.md b/RELEASES.md index 43989f7..fc5c468 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -462,4 +462,14 @@ Based on: ### Generated - [typescript v5.2.0-alpha.3] . ### Releases -- [NPM v5.2.0-alpha.3] https://www.npmjs.com/package/ryan-simple-test-act/v/5.2.0-alpha.3 - . \ No newline at end of file +- [NPM v5.2.0-alpha.3] https://www.npmjs.com/package/ryan-simple-test-act/v/5.2.0-alpha.3 - . + +## 2024-12-16 19:34:37 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.455.7 (2.480.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v5.2.0-alpha.4] . +### Releases +- [NPM v5.2.0-alpha.4] https://www.npmjs.com/package/ryan-simple-test-act/v/5.2.0-alpha.4 - . \ No newline at end of file diff --git a/docs/models/errors/apierrorinvalidinput.md b/docs/models/errors/apierrorinvalidinput.md index fe9fb0e..6edee56 100644 --- a/docs/models/errors/apierrorinvalidinput.md +++ b/docs/models/errors/apierrorinvalidinput.md @@ -1,7 +1,5 @@ # ApiErrorInvalidInput -Not Found error - ## Example Usage ```typescript diff --git a/jsr.json b/jsr.json index c8a76f0..7286f82 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "ryan-simple-test-act", - "version": "5.2.0-alpha.3", + "version": "5.2.0-alpha.4", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 5b6b477..a14d1c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ryan-simple-test-act", - "version": "5.2.0-alpha.3", + "version": "5.2.0-alpha.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ryan-simple-test-act", - "version": "5.2.0-alpha.3", + "version": "5.2.0-alpha.4", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/package.json b/package.json index dcca809..8fecd5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ryan-simple-test-act", - "version": "5.2.0-alpha.3", + "version": "5.2.0-alpha.4", "author": "ryan-timothy-albert", "main": "./index.js", "sideEffects": false, diff --git a/src/funcs/petDeletePet.ts b/src/funcs/petDeletePet.ts index 59a27cf..dca4589 100644 --- a/src/funcs/petDeletePet.ts +++ b/src/funcs/petDeletePet.ts @@ -93,6 +93,7 @@ export async function petDeletePet( const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/petFindPetsByStatusTypes.ts b/src/funcs/petFindPetsByStatusTypes.ts index 837ea7a..d8b3e06 100644 --- a/src/funcs/petFindPetsByStatusTypes.ts +++ b/src/funcs/petFindPetsByStatusTypes.ts @@ -91,6 +91,7 @@ export async function petFindPetsByStatusTypes( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, diff --git a/src/funcs/petFindPetsByTags.ts b/src/funcs/petFindPetsByTags.ts index b5c3c9d..efaf57e 100644 --- a/src/funcs/petFindPetsByTags.ts +++ b/src/funcs/petFindPetsByTags.ts @@ -90,6 +90,7 @@ export async function petFindPetsByTags( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, diff --git a/src/funcs/petGetPetByIDS.ts b/src/funcs/petGetPetByIDS.ts index 82426a3..5ec6aaa 100644 --- a/src/funcs/petGetPetByIDS.ts +++ b/src/funcs/petGetPetByIDS.ts @@ -92,6 +92,7 @@ export async function petGetPetByIDS( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/petMyPet123.ts b/src/funcs/petMyPet123.ts index 8d7bccc..2f78ae4 100644 --- a/src/funcs/petMyPet123.ts +++ b/src/funcs/petMyPet123.ts @@ -81,6 +81,7 @@ export async function petMyPet123( const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/petSit.ts b/src/funcs/petSit.ts index 19439b1..1d444a8 100644 --- a/src/funcs/petSit.ts +++ b/src/funcs/petSit.ts @@ -85,6 +85,7 @@ export async function petSit( const requestRes = client._createRequest(context, { security: requestSecurity, method: "PUT", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/petUploadFile.ts b/src/funcs/petUploadFile.ts index eac5930..a08104f 100644 --- a/src/funcs/petUploadFile.ts +++ b/src/funcs/petUploadFile.ts @@ -90,6 +90,7 @@ export async function petUploadFile( const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, query: query, diff --git a/src/funcs/storeDeleteOrder.ts b/src/funcs/storeDeleteOrder.ts index 179b81f..91e902f 100644 --- a/src/funcs/storeDeleteOrder.ts +++ b/src/funcs/storeDeleteOrder.ts @@ -92,6 +92,7 @@ export async function storeDeleteOrder( const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/storeGetInventory.ts b/src/funcs/storeGetInventory.ts index 34a04a2..e16f5a8 100644 --- a/src/funcs/storeGetInventory.ts +++ b/src/funcs/storeGetInventory.ts @@ -69,6 +69,7 @@ export async function storeGetInventory( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, diff --git a/src/funcs/storeGetOrderById.ts b/src/funcs/storeGetOrderById.ts index 9d43908..cdb439b 100644 --- a/src/funcs/storeGetOrderById.ts +++ b/src/funcs/storeGetOrderById.ts @@ -92,6 +92,7 @@ export async function storeGetOrderById( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/storePlaceOrder.ts b/src/funcs/storePlaceOrder.ts index 1b50d0c..6d9ef9d 100644 --- a/src/funcs/storePlaceOrder.ts +++ b/src/funcs/storePlaceOrder.ts @@ -86,6 +86,7 @@ export async function storePlaceOrder( const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/userCreateUser.ts b/src/funcs/userCreateUser.ts index 849fdc8..0b2dd8d 100644 --- a/src/funcs/userCreateUser.ts +++ b/src/funcs/userCreateUser.ts @@ -83,6 +83,7 @@ export async function userCreateUser( const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/userCreateUsersWithListInput.ts b/src/funcs/userCreateUsersWithListInput.ts index 61ac86e..68c5754 100644 --- a/src/funcs/userCreateUsersWithListInput.ts +++ b/src/funcs/userCreateUsersWithListInput.ts @@ -84,6 +84,7 @@ export async function userCreateUsersWithListInput( const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/userDeleteUser.ts b/src/funcs/userDeleteUser.ts index c472c5a..e19e52a 100644 --- a/src/funcs/userDeleteUser.ts +++ b/src/funcs/userDeleteUser.ts @@ -92,6 +92,7 @@ export async function userDeleteUser( const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/userGetUserByName.ts b/src/funcs/userGetUserByName.ts index 3932f3a..829dcfb 100644 --- a/src/funcs/userGetUserByName.ts +++ b/src/funcs/userGetUserByName.ts @@ -89,6 +89,7 @@ export async function userGetUserByName( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/funcs/userLoginUser.ts b/src/funcs/userLoginUser.ts index 82c8e0a..21606ba 100644 --- a/src/funcs/userLoginUser.ts +++ b/src/funcs/userLoginUser.ts @@ -86,6 +86,7 @@ export async function userLoginUser( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, diff --git a/src/funcs/userLogoutUser.ts b/src/funcs/userLogoutUser.ts index 66622fc..ea151d3 100644 --- a/src/funcs/userLogoutUser.ts +++ b/src/funcs/userLogoutUser.ts @@ -63,6 +63,7 @@ export async function userLogoutUser( const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, diff --git a/src/funcs/userUpdateUser.ts b/src/funcs/userUpdateUser.ts index 65f6fc7..51409e3 100644 --- a/src/funcs/userUpdateUser.ts +++ b/src/funcs/userUpdateUser.ts @@ -89,6 +89,7 @@ export async function userUpdateUser( const requestRes = client._createRequest(context, { security: requestSecurity, method: "PUT", + baseURL: options?.serverURL, path: path, headers: headers, body: body, diff --git a/src/lib/config.ts b/src/lib/config.ts index 8a1e478..bde8cb6 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -81,8 +81,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "4.0.0", - sdkVersion: "5.2.0-alpha.3", - genVersion: "2.477.0", + sdkVersion: "5.2.0-alpha.4", + genVersion: "2.480.1", userAgent: - "speakeasy-sdk/typescript 5.2.0-alpha.3 2.477.0 4.0.0 ryan-simple-test-act", + "speakeasy-sdk/typescript 5.2.0-alpha.4 2.480.1 4.0.0 ryan-simple-test-act", } as const; diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index 2ce720a..334bc3d 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -41,6 +41,10 @@ export type RequestOptions = { * Specifies the status codes which should be retried using the given retry policy. */ retryCodes?: string[]; + /** + * Overrides the base server URL that will be used by an operation. + */ + serverURL?: string | URL; /** * Sets various request options on the `fetch` call made by an SDK method. * @@ -52,7 +56,7 @@ export type RequestOptions = { type RequestConfig = { method: string; path: string; - baseURL?: string | URL; + baseURL?: string | URL | undefined; query?: string; body?: RequestInit["body"]; headers?: HeadersInit; @@ -119,6 +123,7 @@ export class ClientSDK { const inputURL = new URL(path, reqURL); if (path) { + reqURL.pathname += reqURL.pathname.endsWith("/") ? "" : "/"; reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); } diff --git a/src/models/errors/apierrorinvalidinput.ts b/src/models/errors/apierrorinvalidinput.ts index 9ad1368..5d1cd70 100644 --- a/src/models/errors/apierrorinvalidinput.ts +++ b/src/models/errors/apierrorinvalidinput.ts @@ -4,17 +4,11 @@ import * as z from "zod"; -/** - * Not Found error - */ export type ApiErrorInvalidInputData = { status: number; error: string; }; -/** - * Not Found error - */ export class ApiErrorInvalidInput extends Error { status: number; error: string;