diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 17473a2..b3b5e58 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.3" + ".": "0.1.0-alpha.4" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 40cb575..1a0cdc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.4 (2025-01-05) + +Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/nestrilabs/nestri-node-sdk/compare/v0.1.0-alpha.3...v0.1.0-alpha.4) + +### Features + +* **api:** manual updates ([#16](https://github.com/nestrilabs/nestri-node-sdk/issues/16)) ([7819a14](https://github.com/nestrilabs/nestri-node-sdk/commit/7819a1433739f77174a5e97490412125fc14233c)) + ## 0.1.0-alpha.3 (2025-01-04) Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/nestrilabs/nestri-node-sdk/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) diff --git a/README.md b/README.md index c7a085d..79b5fdd 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ The full API of this library can be found in [api.md](api.md). import Nestri from '@nestri/sdk'; const client = new Nestri({ - bearerToken: process.env['BEARER_TOKEN'], // This is the default and can be omitted + bearerToken: process.env['NESTRI_API_KEY'], // This is the default and can be omitted }); async function main() { - const machine = await client.machines.create('fc27f428f9ca47d4b41b70889ae0c62090'); + const game = await client.games.retrieve(870780); - console.log(machine.data); + console.log(game.data); } main(); @@ -44,13 +44,11 @@ This library includes TypeScript definitions for all request params and response import Nestri from '@nestri/sdk'; const client = new Nestri({ - bearerToken: process.env['BEARER_TOKEN'], // This is the default and can be omitted + bearerToken: process.env['NESTRI_API_KEY'], // This is the default and can be omitted }); async function main() { - const machine: Nestri.MachineCreateResponse = await client.machines.create( - 'fc27f428f9ca47d4b41b70889ae0c62090', - ); + const game: Nestri.GameRetrieveResponse = await client.games.retrieve(870780); } main(); @@ -67,7 +65,7 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const machine = await client.machines.create('fc27f428f9ca47d4b41b70889ae0c62090').catch(async (err) => { + const game = await client.games.retrieve(870780).catch(async (err) => { if (err instanceof Nestri.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError @@ -110,7 +108,7 @@ const client = new Nestri({ }); // Or, configure per-request: -await client.machines.create('fc27f428f9ca47d4b41b70889ae0c62090', { +await client.games.retrieve(870780, { maxRetries: 5, }); ``` @@ -127,7 +125,7 @@ const client = new Nestri({ }); // Override per-request: -await client.machines.create('fc27f428f9ca47d4b41b70889ae0c62090', { +await client.games.retrieve(870780, { timeout: 5 * 1000, }); ``` @@ -148,15 +146,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi ```ts const client = new Nestri(); -const response = await client.machines.create('fc27f428f9ca47d4b41b70889ae0c62090').asResponse(); +const response = await client.games.retrieve(870780).asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: machine, response: raw } = await client.machines - .create('fc27f428f9ca47d4b41b70889ae0c62090') - .withResponse(); +const { data: game, response: raw } = await client.games.retrieve(870780).withResponse(); console.log(raw.headers.get('X-My-Header')); -console.log(machine.data); +console.log(game.data); ``` ### Making custom/undocumented requests @@ -260,7 +256,7 @@ const client = new Nestri({ }); // Override per-request: -await client.machines.create('fc27f428f9ca47d4b41b70889ae0c62090', { +await client.games.retrieve(870780, { httpAgent: new http.Agent({ keepAlive: false }), }); ``` diff --git a/package.json b/package.json index 112d8be..1101dd5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nestri/sdk", - "version": "0.1.0-alpha.3", + "version": "0.1.0-alpha.4", "description": "The official TypeScript library for the Nestri API", "author": "Nestri ", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 27b0f85..b81aa68 100644 --- a/src/index.ts +++ b/src/index.ts @@ -104,7 +104,7 @@ export class Nestri extends Core.APIClient { /** * API Client for interfacing with the Nestri API. * - * @param {string | undefined} [opts.bearerToken=process.env['BEARER_TOKEN'] ?? undefined] + * @param {string | undefined} [opts.bearerToken=process.env['NESTRI_API_KEY'] ?? undefined] * @param {string} [opts.baseURL=process.env['NESTRI_BASE_URL'] ?? https://api.nestri.io] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. @@ -115,12 +115,12 @@ export class Nestri extends Core.APIClient { */ constructor({ baseURL = Core.readEnv('NESTRI_BASE_URL'), - bearerToken = Core.readEnv('BEARER_TOKEN'), + bearerToken = Core.readEnv('NESTRI_API_KEY'), ...opts }: ClientOptions = {}) { if (bearerToken === undefined) { throw new Errors.NestriError( - "The BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the Nestri client with an bearerToken option, like new Nestri({ bearerToken: 'My Bearer Token' }).", + "The NESTRI_API_KEY environment variable is missing or empty; either provide it, or instantiate the Nestri client with an bearerToken option, like new Nestri({ bearerToken: 'My Bearer Token' }).", ); } diff --git a/src/version.ts b/src/version.ts index a64b06c..fe6d1df 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.1.0-alpha.3'; // x-release-please-version +export const VERSION = '0.1.0-alpha.4'; // x-release-please-version diff --git a/tests/index.test.ts b/tests/index.test.ts index ba9d6a9..2dc7078 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -195,14 +195,14 @@ describe('instantiate client', () => { test('with environment variable arguments', () => { // set options via env var - process.env['BEARER_TOKEN'] = 'My Bearer Token'; + process.env['NESTRI_API_KEY'] = 'My Bearer Token'; const client = new Nestri(); expect(client.bearerToken).toBe('My Bearer Token'); }); test('with overridden environment variable arguments', () => { // set options via env var - process.env['BEARER_TOKEN'] = 'another My Bearer Token'; + process.env['NESTRI_API_KEY'] = 'another My Bearer Token'; const client = new Nestri({ bearerToken: 'My Bearer Token' }); expect(client.bearerToken).toBe('My Bearer Token'); });