From a32e5f17ea50dcdab8466116efed88aa195362c6 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Tue, 13 Aug 2024 23:18:02 +0530 Subject: [PATCH] Recreated sdk --- .devcontainer/README.md | 9 +-- .devcontainer/setup.sh | 2 +- .speakeasy/gen.lock | 11 ++-- .speakeasy/gen.yaml | 4 +- .speakeasy/workflow.lock | 13 ++--- README.md | 118 +++++++++++++++++++-------------------- RELEASES.md | 11 ---- core.d.ts | 10 ---- core.d.ts.map | 1 - core.js | 17 ------ core.js.map | 1 - jsr.json | 2 +- package-lock.json | 10 ++-- package.json | 6 +- src/lib/config.ts | 4 +- 15 files changed, 82 insertions(+), 137 deletions(-) delete mode 100644 RELEASES.md delete mode 100644 core.d.ts delete mode 100644 core.d.ts.map delete mode 100644 core.js delete mode 100644 core.js.map diff --git a/.devcontainer/README.md b/.devcontainer/README.md index efc70bd..d1f20c3 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -1,9 +1,4 @@ -
- -
-
- > **Remember to shutdown a GitHub Codespace when it is not in use!** # Dev Containers Quick Start @@ -25,11 +20,11 @@ The speakeasy CLI allows you to generate more usage snippets. Here's how: - To generate a sample for a specific operation by providing an operation ID, use: ``` -speakeasy generate usage -s https://ad39-2405-201-3027-2887-d9b-fc28-c7ec-5133.ngrok-free.app/api-json -l typescript -i {INPUT_OPERATION_ID} -o ./samples +speakeasy generate usage -s https://1573-2405-201-3027-2887-ada2-ca7a-fa63-8ab5.ngrok-free.app/api-json -l typescript -i {INPUT_OPERATION_ID} -o ./samples ``` - To generate samples for an entire namespace (like a tag or group name), use: ``` -speakeasy generate usage -s https://ad39-2405-201-3027-2887-d9b-fc28-c7ec-5133.ngrok-free.app/api-json -l typescript -n {INPUT_TAG_NAME} -o ./samples +speakeasy generate usage -s https://1573-2405-201-3027-2887-ada2-ca7a-fa63-8ab5.ngrok-free.app/api-json -l typescript -n {INPUT_TAG_NAME} -o ./samples ``` diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 1dcd231..33dc11b 100644 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -27,4 +27,4 @@ EOL echo "$TS_CONFIG_CONTENT" > samples/tsconfig.json # Generate starter usage sample with speakeasy -speakeasy generate usage -s https://ad39-2405-201-3027-2887-d9b-fc28-c7ec-5133.ngrok-free.app/api-json -l typescript -o samples/root.ts \ No newline at end of file +speakeasy generate usage -s https://1573-2405-201-3027-2887-ada2-ca7a-fa63-8ab5.ngrok-free.app/api-json -l typescript -o samples/root.ts \ No newline at end of file diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 834bdd7..53b2bcd 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,15 +1,12 @@ lockVersion: 2.0.0 -id: 87cc6b1a-13e6-4501-a0d7-2da24669a204 +id: d92d2248-44a7-4f20-939b-4f5a23e38b07 management: - docChecksum: 216841ffd9a1defdd89e16a73e33178f + docChecksum: 220c1ffbe0b2bf1cd15b2d1575d4672f docVersion: Beta speakeasyVersion: 1.363.1 generationVersion: 2.396.0 - releaseVersion: 0.5.0 - configChecksum: 28bc2c234c5dadf029b3d2fe8a97e020 - repoURL: https://github.com/ava-labs/avalanche-sdk-typescript.git - installationURL: https://github.com/ava-labs/avalanche-sdk-typescript - published: true + releaseVersion: 0.1.0 + configChecksum: c0c67af710ca750216d343337f758691 features: typescript: additionalDependencies: 0.1.0 diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 892862a..8730622 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -2,7 +2,7 @@ configVersion: 2.0.0 generation: devContainers: enabled: true - schemaPath: https://ad39-2405-201-3027-2887-d9b-fc28-c7ec-5133.ngrok-free.app/api-json + schemaPath: https://1573-2405-201-3027-2887-ada2-ca7a-fa63-8ab5.ngrok-free.app/api-json sdkClassName: AvalancheSdk maintainOpenAPIOrder: true usageSnippets: @@ -15,7 +15,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: false typescript: - version: 0.5.0 + version: 0.1.0 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 94d1be8..f4a05e3 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,17 +1,17 @@ -speakeasyVersion: 1.361.1 +speakeasyVersion: 1.354.1 sources: AvalancheSDK-OAS: sourceNamespace: avalanche-sdk-oas - sourceRevisionDigest: sha256:df5ede97c87fa9ae15088257f01d3ea7f03a491aa924f3c0476150ad78da77bc - sourceBlobDigest: sha256:19288be87bfa93e83d436d3165f4d3599a0053d7b114aba0b38a35775c43df5f + sourceRevisionDigest: sha256:19c414a56967df33cbf409cce182bde24b3dc711adc130dc5b8c66a0dc340dd0 + sourceBlobDigest: sha256:678f76fcf9d681c0c1940d0f09d8d9d77a5d9c44eca1d37c7bf9528bedb70d29 tags: - latest targets: avalanche-sdk: source: AvalancheSDK-OAS sourceNamespace: avalanche-sdk-oas - sourceRevisionDigest: sha256:df5ede97c87fa9ae15088257f01d3ea7f03a491aa924f3c0476150ad78da77bc - sourceBlobDigest: sha256:19288be87bfa93e83d436d3165f4d3599a0053d7b114aba0b38a35775c43df5f + sourceRevisionDigest: sha256:19c414a56967df33cbf409cce182bde24b3dc711adc130dc5b8c66a0dc340dd0 + sourceBlobDigest: sha256:678f76fcf9d681c0c1940d0f09d8d9d77a5d9c44eca1d37c7bf9528bedb70d29 outLocation: /Users/sayan.kar/avalabs/avalanche-sdk-typescript workflow: workflowVersion: 1.0.0 @@ -27,6 +27,3 @@ workflow: avalanche-sdk: target: typescript source: AvalancheSDK-OAS - publish: - npm: - token: $npm_token diff --git a/README.md b/README.md index 2babbdb..2d4b6a4 100644 --- a/README.md +++ b/README.md @@ -22,25 +22,25 @@ It has been generated successfully based on your OpenAPI spec. However, it is no ### NPM ```bash -npm add @avalabs/avalanche-sdk +npm add ``` ### PNPM ```bash -pnpm add @avalabs/avalanche-sdk +pnpm add ``` ### Bun ```bash -bun add @avalabs/avalanche-sdk +bun add ``` ### Yarn ```bash -yarn add @avalabs/avalanche-sdk zod +yarn add zod # Note that Yarn does not install peer dependencies automatically. You will need # to install zod as shown above. @@ -239,6 +239,46 @@ run(); * [getChainInfo](docs/sdks/chains/README.md#getchaininfo) - Get chain information + +## Global Parameters + +Certain parameters are configured globally. These parameters may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, These global values will be used as defaults on the operations that use them. When such operations are called, there is a place in each to override the global value, if needed. + +For example, you can set `chainId` to `""` at SDK initialization and then you do not have to pass the same value on calls to operations like `listChains`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration. + + +### Available Globals + +The following global parameters are available. + +| Name | Type | Required | Description | +| ---- | ---- |:--------:| ----------- | +| chainId | string | | The chainId parameter. | +| network | string | | The network parameter. | + + +### Example + +```typescript +import { AvalancheSDK } from "@avalabs/avalanche-sdk"; + +const avalancheSDK = new AvalancheSDK(); + +async function run() { + const result = await avalancheSDK.metrics.evm.chains.listChains({ + network: "mainnet", + }); + + for await (const page of result) { + // handle page + } +} + +run(); + +``` + + ## Pagination @@ -480,61 +520,6 @@ const sdk = new AvalancheSDK({ httpClient }); ``` - -## Debugging - -To log HTTP requests and responses, you can pass a logger that matches `console`'s interface as an SDK option. - -> [!WARNING] -> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. - -```typescript -import { AvalancheSDK } from "@avalabs/avalanche-sdk"; - -const sdk = new AvalancheSDK({ debugLogger: console }); -``` - - - -## Global Parameters - -Certain parameters are configured globally. These parameters may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, These global values will be used as defaults on the operations that use them. When such operations are called, there is a place in each to override the global value, if needed. - -For example, you can set `chainId` to `""` at SDK initialization and then you do not have to pass the same value on calls to operations like `listChains`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration. - - -### Available Globals - -The following global parameters are available. - -| Name | Type | Required | Description | -| ---- | ---- |:--------:| ----------- | -| chainId | string | | The chainId parameter. | -| network | string | | The network parameter. | - - -### Example - -```typescript -import { AvalancheSDK } from "@avalabs/avalanche-sdk"; - -const avalancheSDK = new AvalancheSDK(); - -async function run() { - const result = await avalancheSDK.metrics.evm.chains.listChains({ - network: "mainnet", - }); - - for await (const page of result) { - // handle page - } -} - -run(); - -``` - - ## Standalone functions @@ -645,6 +630,21 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). + +## Debugging + +To log HTTP requests and responses, you can pass a logger that matches `console`'s interface as an SDK option. + +> [!WARNING] +> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production. + +```typescript +import { AvalancheSDK } from "@avalabs/avalanche-sdk"; + +const sdk = new AvalancheSDK({ debugLogger: console }); +``` + + # Development diff --git a/RELEASES.md b/RELEASES.md deleted file mode 100644 index f59c1e6..0000000 --- a/RELEASES.md +++ /dev/null @@ -1,11 +0,0 @@ - - -## 2024-08-09 12:40:29 -### Changes -Based on: -- OpenAPI Doc -- Speakeasy CLI 1.358.0 (2.390.6) https://github.com/speakeasy-api/speakeasy -### Generated -- [typescript v0.0.2] . -### Releases -- [NPM v0.0.2] https://www.npmjs.com/package/@avalabs/avalanche-sdk/v/0.0.2 - . \ No newline at end of file diff --git a/core.d.ts b/core.d.ts deleted file mode 100644 index 2208c78..0000000 --- a/core.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ClientSDK } from "./lib/sdks.js"; -/** - * A minimal client to use when calling standalone SDK functions. Typically, an - * instance of this class would be instantiated once at the start of an - * application and passed around through some dependency injection mechanism to - * parts of an application that need to make SDK calls. - */ -export declare class AvalancheSDKCore extends ClientSDK { -} -//# sourceMappingURL=core.d.ts.map \ No newline at end of file diff --git a/core.d.ts.map b/core.d.ts.map deleted file mode 100644 index 7291462..0000000 --- a/core.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["src/core.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;CAAG"} \ No newline at end of file diff --git a/core.js b/core.js deleted file mode 100644 index 92b247a..0000000 --- a/core.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -/* - * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AvalancheSDKCore = void 0; -const sdks_js_1 = require("./lib/sdks.js"); -/** - * A minimal client to use when calling standalone SDK functions. Typically, an - * instance of this class would be instantiated once at the start of an - * application and passed around through some dependency injection mechanism to - * parts of an application that need to make SDK calls. - */ -class AvalancheSDKCore extends sdks_js_1.ClientSDK { -} -exports.AvalancheSDKCore = AvalancheSDKCore; -//# sourceMappingURL=core.js.map \ No newline at end of file diff --git a/core.js.map b/core.js.map deleted file mode 100644 index bb4dd2a..0000000 --- a/core.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"core.js","sourceRoot":"","sources":["src/core.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2CAA0C;AAE1C;;;;;GAKG;AACH,MAAa,gBAAiB,SAAQ,mBAAS;CAAG;AAAlD,4CAAkD"} \ No newline at end of file diff --git a/jsr.json b/jsr.json index 868ef8a..95a24b2 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@avalabs/avalanche-sdk", - "version": "0.5.0", + "version": "0.1.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 16bb7c5..20ed2de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@avalabs/avalanche-sdk", - "version": "0.5.0", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@avalabs/avalanche-sdk", - "version": "0.5.0", + "version": "0.1.0", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", @@ -1735,9 +1735,9 @@ } }, "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "engines": { "node": ">= 4" diff --git a/package.json b/package.json index 1aa7004..cbdb3e1 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,9 @@ { "name": "@avalabs/avalanche-sdk", - "version": "0.5.0", + "version": "0.1.0", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, - "repository": { - "type": "git", - "url": "https://github.com/ava-labs/avalanche-sdk-typescript.git" - }, "scripts": { "lint": "eslint --max-warnings=0 src", "build": "tsc", diff --git a/src/lib/config.ts b/src/lib/config.ts index 14042c0..422cf3f 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -47,7 +47,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "Beta", - sdkVersion: "0.5.0", + sdkVersion: "0.1.0", genVersion: "2.396.0", - userAgent: "speakeasy-sdk/typescript 0.5.0 2.396.0 Beta @avalabs/avalanche-sdk", + userAgent: "speakeasy-sdk/typescript 0.1.0 2.396.0 Beta @avalabs/avalanche-sdk", } as const;