Skip to content

chore: 🐝 Update SDK - Generate 0.25.0 #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
629 changes: 613 additions & 16 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ generation:
generateNewTests: true
skipResponseBodyAssertions: false
typescript:
version: 0.24.1
version: 0.25.0
additionalDependencies:
dependencies: {}
devDependencies: {}
peerDependencies: {}
additionalPackageJSON: {}
author: Speakeasy
baseErrorName: ApideckError
clientServerStatusCodesAsErrors: true
defaultErrorName: APIError
enableCustomCodeRegions: false
Expand Down
14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
speakeasyVersion: 1.555.0
speakeasyVersion: 1.559.0
sources:
Apideck-OAS:
sourceNamespace: apideck-oas
sourceRevisionDigest: sha256:dfd8bf44ffd797bd01ed1dcb3c44becb2f7199d271108c1c00340fa5e6c9e259
sourceBlobDigest: sha256:56d1ef43c8d49e89407bc967e1cd9b9eeb54029bf17113e1c6914056084805da
sourceRevisionDigest: sha256:bd0b9d7f0319e40714550f4804ac44d6ac7f3ef1346eb26a972d44ce46ac0fba
sourceBlobDigest: sha256:b16d87c11cc9c5bbff0fc829bd6621927e10f79ff8f16a6b6eddd3b1bf56e8a1
tags:
- latest
- speakeasy-sdk-regen-1748856960
- speakeasy-sdk-regen-1749226423
- 10.17.2
targets:
apideck:
source: Apideck-OAS
sourceNamespace: apideck-oas
sourceRevisionDigest: sha256:dfd8bf44ffd797bd01ed1dcb3c44becb2f7199d271108c1c00340fa5e6c9e259
sourceBlobDigest: sha256:56d1ef43c8d49e89407bc967e1cd9b9eeb54029bf17113e1c6914056084805da
sourceRevisionDigest: sha256:bd0b9d7f0319e40714550f4804ac44d6ac7f3ef1346eb26a972d44ce46ac0fba
sourceBlobDigest: sha256:b16d87c11cc9c5bbff0fc829bd6621927e10f79ff8f16a6b6eddd3b1bf56e8a1
codeSamplesNamespace: apideck-oas-typescript-code-samples
codeSamplesRevisionDigest: sha256:a29b5e75f9bed069b68f15f829ab6db1367bd3b5b8181e73b1393450324b9512
codeSamplesRevisionDigest: sha256:14c55248868d8910ef92a44aac87cbfd4e88eba070457afb5c72608a3585d047
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
31 changes: 7 additions & 24 deletions FUNCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ specific category of applications.
```typescript
import { ApideckCore } from "@apideck/unify/core.js";
import { accountingTaxRatesList } from "@apideck/unify/funcs/accountingTaxRatesList.js";
import { SDKValidationError } from "@apideck/unify/models/errors/sdkvalidationerror.js";

// Use `ApideckCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const apideck = new ApideckCore({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -46,30 +45,14 @@ async function run() {
},
fields: "id,updated_at",
});

switch (true) {
case res.ok:
// The success case will be handled outside of the switch block
break;
case res.error instanceof SDKValidationError:
// Pretty-print validation errors.
return console.log(res.error.pretty());
case res.error instanceof Error:
return console.log(res.error);
default:
// TypeScript's type checking will fail on the following line if the above
// cases were not exhaustive.
res.error satisfies never;
throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error);
}


const { value: result } = res;

for await (const page of result) {
// Handle the page
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("accountingTaxRatesList failed:", res.error);
}
}

run();
Expand Down
143 changes: 58 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -111,7 +111,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand Down Expand Up @@ -1011,9 +1010,9 @@ Here's an example of one such pagination call:
import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -1033,7 +1032,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand Down Expand Up @@ -1062,9 +1060,9 @@ import { Apideck } from "@apideck/unify";
import { openAsBlob } from "node:fs";

const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -1077,7 +1075,6 @@ async function run() {
requestBody: await openAsBlob("example.file"),
});

// Handle the result
console.log(result);
}

Expand All @@ -1096,9 +1093,9 @@ To change the default retry strategy for a single API call, simply provide a ret
import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand Down Expand Up @@ -1129,7 +1126,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand All @@ -1153,9 +1149,9 @@ const apideck = new Apideck({
},
retryConnectionErrors: false,
},
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -1175,7 +1171,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand All @@ -1188,40 +1183,29 @@ run();
<!-- Start Error Handling [errors] -->
## Error Handling

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 `list` method may throw the following errors:
[`ApideckError`](./src/models/errors/apideckerror.ts) is the base class for all HTTP error responses. It has the following properties:

| Error Type | Status Code | Content Type |
| ------------------------------ | ----------- | ---------------- |
| errors.BadRequestResponse | 400 | application/json |
| errors.UnauthorizedResponse | 401 | application/json |
| errors.PaymentRequiredResponse | 402 | application/json |
| errors.NotFoundResponse | 404 | application/json |
| errors.UnprocessableResponse | 422 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |

If the method throws an error and it is not captured by the known errors, it will default to throwing a `APIError`.
| Property | Type | Description |
| ------------------------- | ---------- | --------------------------------------------------------------------------------------- |
| `error.message` | `string` | Error message |
| `error.httpMeta.response` | `Response` | HTTP response. Access to headers and more. |
| `error.httpMeta.request` | `Request` | HTTP request. Access to headers and more. |
| `error.data$` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |

### Example
```typescript
import { Apideck } from "@apideck/unify";
import {
BadRequestResponse,
NotFoundResponse,
PaymentRequiredResponse,
SDKValidationError,
UnauthorizedResponse,
UnprocessableResponse,
} from "@apideck/unify/models/errors";
import * as errors from "@apideck/unify/models/errors";

const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
let result;
try {
result = await apideck.accounting.taxRates.list({
const result = await apideck.accounting.taxRates.list({
serviceId: "salesforce",
filter: {
assets: true,
Expand All @@ -1237,47 +1221,23 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
} catch (err) {
switch (true) {
// The server response does not match the expected SDK schema
case (err instanceof SDKValidationError): {
// 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);
return;
}
case (err instanceof BadRequestResponse): {
// Handle err.data$: BadRequestResponseData
console.error(err);
return;
}
case (err instanceof UnauthorizedResponse): {
// Handle err.data$: UnauthorizedResponseData
console.error(err);
return;
}
case (err instanceof PaymentRequiredResponse): {
// Handle err.data$: PaymentRequiredResponseData
console.error(err);
return;
}
case (err instanceof NotFoundResponse): {
// Handle err.data$: NotFoundResponseData
console.error(err);
return;
}
case (err instanceof UnprocessableResponse): {
// Handle err.data$: UnprocessableResponseData
console.error(err);
return;
}
default: {
// Other errors such as network errors, see HTTPClientErrors for more details
throw err;
} catch (error) {
// The base class for HTTP error responses
if (error instanceof errors.ApideckError) {
console.log(error.message);
console.log(error.httpMeta.response.status);
console.log(error.httpMeta.response.headers);
console.log(error.httpMeta.request);

// Depending on the method different errors may be thrown
if (error instanceof errors.BadRequestResponse) {
console.log(error.data$.statusCode); // number
console.log(error.data$.error); // string
console.log(error.data$.typeName); // string
console.log(error.data$.message); // string
console.log(error.data$.detail); // errors.Detail
}
}
}
Expand All @@ -1287,17 +1247,33 @@ 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 multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging.
### Error Classes
**Primary errors:**
* [`ApideckError`](./src/models/errors/apideckerror.ts): The base class for HTTP error responses.
* [`UnauthorizedResponse`](docs/models/errors/unauthorizedresponse.md): Unauthorized. Status code `401`.
* [`PaymentRequiredResponse`](docs/models/errors/paymentrequiredresponse.md): Payment Required. Status code `402`.
* [`NotFoundResponse`](docs/models/errors/notfoundresponse.md): The specified resource was not found. Status code `404`. *
* [`BadRequestResponse`](docs/models/errors/badrequestresponse.md): Bad Request. Status code `400`. *
* [`UnprocessableResponse`](docs/models/errors/unprocessableresponse.md): Unprocessable. Status code `422`. *

<details><summary>Less common errors (6)</summary>

<br />

**Network errors:**
* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.

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 |
**Inherit from [`ApideckError`](./src/models/errors/apideckerror.ts)**:
* [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.

</details>

\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
<!-- End Error Handling [errors] -->

<!-- Start Server Selection [server] -->
Expand All @@ -1311,9 +1287,9 @@ import { Apideck } from "@apideck/unify";

const apideck = new Apideck({
serverURL: "https://unify.apideck.com",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -1333,7 +1309,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand All @@ -1350,9 +1325,9 @@ import { Apideck } from "@apideck/unify";
import { openAsBlob } from "node:fs";

const apideck = new Apideck({
apiKey: process.env["APIDECK_API_KEY"] ?? "",
consumerId: "test-consumer",
appId: "dSBdXd2H6Mqwfg0atXHXYcysLJE9qyn1VwBtXHX",
apiKey: process.env["APIDECK_API_KEY"] ?? "",
});

async function run() {
Expand All @@ -1367,7 +1342,6 @@ async function run() {
serverURL: "https://upload.apideck.com",
});

// Handle the result
console.log(result);
}

Expand Down Expand Up @@ -1463,7 +1437,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand Down
Loading