Skip to content

chore: 🐝 Update SDK - Generate 0.12.2 #57

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 2 commits into from
Jun 16, 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
  •  
  •  
  •  
3,461 changes: 2,922 additions & 539 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 @@ -20,7 +20,7 @@ generation:
oAuth2ClientCredentialsEnabled: false
oAuth2PasswordEnabled: false
typescript:
version: 0.12.1
version: 0.12.2
additionalDependencies:
dependencies:
json-canonicalize: ^1.0.6
Expand All @@ -31,6 +31,7 @@ typescript:
homepage: https://developer.avacloud.io/avacloud-sdk/getting-started
license: SEE LICENSE
author: AvaCloud
baseErrorName: AvaCloudSDKError
clientServerStatusCodesAsErrors: true
defaultErrorName: SDKError
enableCustomCodeRegions: false
Expand Down
14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
speakeasyVersion: 1.555.0
speakeasyVersion: 1.563.1
sources:
AvaCloudSDK-OAS:
sourceNamespace: avacloud-sdk-oas
sourceRevisionDigest: sha256:442cc3ce513718c1686efed1b4ec323982e49b2ea2fd111a02c4fc07da855c43
sourceBlobDigest: sha256:46ea12e8708a5d254d41034432ee7b7f1985478cc9de3ddcfe6f6f3046f93b25
sourceRevisionDigest: sha256:31f8da12f86c2d62f17221a4778c46288b862d4abbbaa8d13f683be009ef2b87
sourceBlobDigest: sha256:b99c9804e12a5f0bfd8428e995e8be1638c6f57de29b83b0bb67d5fdc62a862c
tags:
- latest
- speakeasy-sdk-regen-1748900446
- speakeasy-sdk-regen-1749255134
- 1.0.0
AvalancheSDK-OAS:
sourceNamespace: avalanche-sdk-oas
Expand All @@ -19,10 +19,10 @@ targets:
avacloud-sdk:
source: AvaCloudSDK-OAS
sourceNamespace: avacloud-sdk-oas
sourceRevisionDigest: sha256:442cc3ce513718c1686efed1b4ec323982e49b2ea2fd111a02c4fc07da855c43
sourceBlobDigest: sha256:46ea12e8708a5d254d41034432ee7b7f1985478cc9de3ddcfe6f6f3046f93b25
sourceRevisionDigest: sha256:31f8da12f86c2d62f17221a4778c46288b862d4abbbaa8d13f683be009ef2b87
sourceBlobDigest: sha256:b99c9804e12a5f0bfd8428e995e8be1638c6f57de29b83b0bb67d5fdc62a862c
codeSamplesNamespace: avacloud-sdk-ts-code-samples
codeSamplesRevisionDigest: sha256:876348a888a52d549ea50086546f2c2465129e9e012fc65ba9074db6fe222aaa
codeSamplesRevisionDigest: sha256:7883f1c4fd7d84882c7f9074e782b7feb70228b65f3e388773e3859593e8fe03
avalanche-sdk:
source: AvalancheSDK-OAS
sourceNamespace: avalanche-sdk-oas
Expand Down
29 changes: 5 additions & 24 deletions FUNCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,21 @@ specific category of applications.
```typescript
import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { metricsHealthCheck } from "@avalabs/avacloud-sdk/funcs/metricsHealthCheck.js";
import { SDKValidationError } from "@avalabs/avacloud-sdk/models/errors/sdkvalidationerror.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
serverURL: "https://api.example.com",
chainId: "43114",
network: "mainnet",
});

async function run() {
const res = await metricsHealthCheck(avaCloudSDK);

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);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("metricsHealthCheck failed:", res.error);
}


const { value: result } = res;

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

run();
Expand Down
165 changes: 61 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
serverURL: "https://api.example.com",
chainId: "43114",
network: "mainnet",
});

async function run() {
Expand Down Expand Up @@ -550,6 +548,13 @@ run();
* [listTokenHoldersAboveThreshold](docs/sdks/chains/README.md#listtokenholdersabovethreshold) - Get addresses by balance over time
* [listBTCbBridgersAboveThreshold](docs/sdks/chains/README.md#listbtcbbridgersabovethreshold) - Get addresses by BTCb bridged balance

#### [metrics.l1Validators](docs/sdks/l1validators/README.md)

* [listMetrics](docs/sdks/l1validators/README.md#listmetrics) - Get given metric for all validators
* [getMetricsByValidationId](docs/sdks/l1validators/README.md#getmetricsbyvalidationid) - Get metric values with given validation id and timestamp range
* [getMetricsByNodeId](docs/sdks/l1validators/README.md#getmetricsbynodeid) - Get metric values with given node id and timestamp range
* [getMetricsBySubnetId](docs/sdks/l1validators/README.md#getmetricsbysubnetid) - Get metric values with given subnet ID and timestamp range

#### [metrics.networks](docs/sdks/networks/README.md)

* [getStakingMetrics](docs/sdks/networks/README.md#getstakingmetrics) - Get staking metrics for a given subnet
Expand Down Expand Up @@ -666,6 +671,10 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).
- [`metricsChainsListNftHolders`](docs/sdks/chains/README.md#listnftholders) - Get NFT holders by contract address
- [`metricsChainsListTokenHoldersAboveThreshold`](docs/sdks/chains/README.md#listtokenholdersabovethreshold) - Get addresses by balance over time
- [`metricsHealthCheck`](docs/sdks/metrics/README.md#healthcheck) - Get the health of the service
- [`metricsL1ValidatorsGetMetricsByNodeId`](docs/sdks/l1validators/README.md#getmetricsbynodeid) - Get metric values with given node id and timestamp range
- [`metricsL1ValidatorsGetMetricsBySubnetId`](docs/sdks/l1validators/README.md#getmetricsbysubnetid) - Get metric values with given subnet ID and timestamp range
- [`metricsL1ValidatorsGetMetricsByValidationId`](docs/sdks/l1validators/README.md#getmetricsbyvalidationid) - Get metric values with given validation id and timestamp range
- [`metricsL1ValidatorsListMetrics`](docs/sdks/l1validators/README.md#listmetrics) - Get given metric for all validators
- [`metricsNetworksGetStakingMetrics`](docs/sdks/networks/README.md#getstakingmetrics) - Get staking metrics for a given subnet
- [`metricsSubnetsGetValidators`](docs/sdks/subnets/README.md#getvalidators) - Get addresses running validators during a given time frame
- [`webhooksAddressesAdd`](docs/sdks/addresses/README.md#add) - Add addresses to EVM activity webhook
Expand Down Expand Up @@ -737,7 +746,6 @@ async function run() {
});

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand All @@ -764,8 +772,6 @@ import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
serverURL: "https://api.example.com",
chainId: "43114",
network: "mainnet",
});

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

for await (const page of result) {
// Handle the page
console.log(page);
}
}
Expand All @@ -795,8 +800,6 @@ import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
serverURL: "https://api.example.com",
chainId: "43114",
network: "mainnet",
});

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

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

Expand All @@ -837,14 +839,11 @@ const avaCloudSDK = new AvaCloudSDK({
},
retryConnectionErrors: false,
},
chainId: "43114",
network: "mainnet",
});

async function run() {
const result = await avaCloudSDK.metrics.healthCheck();

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

Expand All @@ -856,102 +855,46 @@ 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 `reindex` method may throw the following errors:
[`AvaCloudSDKError`](./src/models/errors/avacloudsdkerror.ts) is the base class for all HTTP error responses. It has the following properties:

| Error Type | Status Code | Content Type |
| -------------------------- | ----------- | ---------------- |
| errors.BadRequest | 400 | application/json |
| errors.Unauthorized | 401 | application/json |
| errors.Forbidden | 403 | application/json |
| errors.NotFound | 404 | application/json |
| errors.TooManyRequests | 429 | application/json |
| errors.InternalServerError | 500 | application/json |
| errors.BadGateway | 502 | application/json |
| errors.ServiceUnavailable | 503 | 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`.
| Property | Type | Description |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| `error.message` | `string` | Error message |
| `error.statusCode` | `number` | HTTP response status code eg `404` |
| `error.headers` | `Headers` | HTTP response headers |
| `error.body` | `string` | HTTP body. Can be empty string if no body is returned. |
| `error.rawResponse` | `Response` | Raw HTTP response |
| `error.data$` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |

### Example
```typescript
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
import {
BadGateway,
BadRequest,
Forbidden,
InternalServerError,
NotFound,
SDKValidationError,
ServiceUnavailable,
TooManyRequests,
Unauthorized,
} from "@avalabs/avacloud-sdk/models/errors";
import * as errors from "@avalabs/avacloud-sdk/models/errors";

const avaCloudSDK = new AvaCloudSDK({
serverURL: "https://api.example.com",
chainId: "43114",
network: "mainnet",
});

async function run() {
try {
await avaCloudSDK.data.nfts.reindex({
chainId: "43114",
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
tokenId: "145",
});
} 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 BadRequest): {
// Handle err.data$: BadRequestData
console.error(err);
return;
}
case (err instanceof Unauthorized): {
// Handle err.data$: UnauthorizedData
console.error(err);
return;
}
case (err instanceof Forbidden): {
// Handle err.data$: ForbiddenData
console.error(err);
return;
}
case (err instanceof NotFound): {
// Handle err.data$: NotFoundData
console.error(err);
return;
}
case (err instanceof TooManyRequests): {
// Handle err.data$: TooManyRequestsData
console.error(err);
return;
}
case (err instanceof InternalServerError): {
// Handle err.data$: InternalServerErrorData
console.error(err);
return;
}
case (err instanceof BadGateway): {
// Handle err.data$: BadGatewayData
console.error(err);
return;
}
case (err instanceof ServiceUnavailable): {
// Handle err.data$: ServiceUnavailableData
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.AvaCloudSDKError) {
console.log(error.message);
console.log(error.statusCode);
console.log(error.body);
console.log(error.headers);

// Depending on the method different errors may be thrown
if (error instanceof errors.BadRequest) {
console.log(error.data$.message); // errors.Message
console.log(error.data$.statusCode); // number
console.log(error.data$.error); // string
}
}
}
Expand All @@ -961,17 +904,34 @@ 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:**
* [`AvaCloudSDKError`](./src/models/errors/avacloudsdkerror.ts): The base class for HTTP error responses.
* [`BadRequest`](docs/models/errors/badrequest.md): Bad requests generally mean the client has passed invalid or malformed parameters. Error messages in the response could help in evaluating the error. Status code `400`.
* [`Unauthorized`](docs/models/errors/unauthorized.md): When a client attempts to access resources that require authorization credentials but the client lacks proper authentication in the request, the server responds with 401. Status code `401`.
* [`Forbidden`](docs/models/errors/forbidden.md): When a client attempts to access resources with valid credentials but doesn't have the privilege to perform that action, the server responds with 403. Status code `403`.
* [`NotFound`](docs/models/errors/notfound.md): The error is mostly returned when the client requests with either mistyped URL, or the passed resource is moved or deleted, or the resource doesn't exist. Status code `404`.
* [`TooManyRequests`](docs/models/errors/toomanyrequests.md): This error is returned when the client has sent too many, and has hit the rate limit. Status code `429`.
* [`InternalServerError`](docs/models/errors/internalservererror.md): The error is a generic server side error that is returned for any uncaught and unexpected issues on the server side. This should be very rare, and you may reach out to us if the problem persists for a longer duration. Status code `500`.
* [`BadGateway`](docs/models/errors/badgateway.md): This is an internal error indicating invalid response received by the client-facing proxy or gateway from the upstream server. Status code `502`.
* [`ServiceUnavailable`](docs/models/errors/serviceunavailable.md): The error is returned for certain routes on a particular Subnet. This indicates an internal problem with our Subnet node, and may not necessarily mean the Subnet is down or affected. Status code `503`.

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:
<details><summary>Less common errors (6)</summary>

| 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 |
<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.


**Inherit from [`AvaCloudSDKError`](./src/models/errors/avacloudsdkerror.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>
<!-- End Error Handling [errors] -->

<!-- Start Custom HTTP Client [http-client] -->
Expand Down Expand Up @@ -1041,14 +1001,11 @@ import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
const avaCloudSDK = new AvaCloudSDK({
serverURL: "https://api.example.com",
apiKey: "<YOUR_API_KEY_HERE>",
chainId: "43114",
network: "mainnet",
});

async function run() {
const result = await avaCloudSDK.metrics.healthCheck();

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

Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,14 @@ Based on:
### Generated
- [typescript v0.12.1] .
### Releases
- [NPM v0.12.1] https://www.npmjs.com/package/@avalabs/avacloud-sdk/v/0.12.1 - .
- [NPM v0.12.1] https://www.npmjs.com/package/@avalabs/avacloud-sdk/v/0.12.1 - .

## 2025-06-16 00:12:35
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.563.1 (2.629.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v0.12.2] .
### Releases
- [NPM v0.12.2] https://www.npmjs.com/package/@avalabs/avacloud-sdk/v/0.12.2 - .
Loading