-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): OpenAPI spec update via Stainless API (#15)
- Loading branch information
1 parent
861f35c
commit 55303bb
Showing
57 changed files
with
1,330 additions
and
810 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 42 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-a0403cd987757a0e69e2bffb8a87a8cf4a848a8c35d35ed5eb34cf4649a9b5d0.yml | ||
configured_endpoints: 48 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-05e51d588b47a6124e7af1cd591b6d1ec254edeba03c4fd499ac905d4687cb6d.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Metronome Node API Library | ||
|
||
[![NPM version](https://img.shields.io/npm/v/metronome.svg)](https://npmjs.org/package/metronome) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/metronome) | ||
[![NPM version](https://img.shields.io/npm/v/@metronome/sdk.svg)](https://npmjs.org/package/@metronome/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@metronome/sdk) | ||
|
||
This library provides convenient access to the Metronome REST API from server-side TypeScript or JavaScript. | ||
|
||
|
@@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/). | |
## Installation | ||
|
||
```sh | ||
npm install metronome | ||
npm install @metronome/sdk | ||
``` | ||
|
||
## Usage | ||
|
@@ -20,20 +20,23 @@ The full API of this library can be found in [api.md](api.md). | |
|
||
<!-- prettier-ignore --> | ||
```js | ||
import Metronome from 'metronome'; | ||
import Metronome from '@metronome/sdk'; | ||
|
||
const metronome = new Metronome({ | ||
bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted | ||
}); | ||
|
||
async function main() { | ||
const alertCreateResponse = await metronome.alerts.create({ | ||
alert_type: 'spend_threshold_reached', | ||
name: '$100 spend threshold reached', | ||
threshold: 10000, | ||
const response = await metronome.usage.ingest({ | ||
usage: [ | ||
{ | ||
transaction_id: '2021-01-01T00:00:00Z_cluster42', | ||
customer_id: '[email protected]', | ||
event_type: 'heartbeat', | ||
timestamp: '2021-01-01T00:00:00Z', | ||
}, | ||
], | ||
}); | ||
|
||
console.log(alertCreateResponse.data); | ||
} | ||
|
||
main(); | ||
|
@@ -45,7 +48,7 @@ This library includes TypeScript definitions for all request params and response | |
|
||
<!-- prettier-ignore --> | ||
```ts | ||
import Metronome from 'metronome'; | ||
import Metronome from '@metronome/sdk'; | ||
|
||
const metronome = new Metronome({ | ||
bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted | ||
|
@@ -225,11 +228,11 @@ add the following import before your first import `from "Metronome"`: | |
```ts | ||
// Tell TypeScript and the package to use the global web fetch instead of node-fetch. | ||
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed. | ||
import 'metronome/shims/web'; | ||
import Metronome from 'metronome'; | ||
import '@metronome/sdk/shims/web'; | ||
import Metronome from '@metronome/sdk'; | ||
``` | ||
|
||
To do the inverse, add `import "metronome/shims/node"` (which does import polyfills). | ||
To do the inverse, add `import "@metronome/sdk/shims/node"` (which does import polyfills). | ||
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/Metronome-Industries/metronome-node/tree/main/src/_shims#readme)). | ||
|
||
### Logging and middleware | ||
|
@@ -239,7 +242,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e | |
|
||
```ts | ||
import { fetch } from 'undici'; // as one example | ||
import Metronome from 'metronome'; | ||
import Metronome from '@metronome/sdk'; | ||
|
||
const client = new Metronome({ | ||
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => { | ||
|
@@ -298,7 +301,7 @@ TypeScript >= 4.5 is supported. | |
The following runtimes are supported: | ||
|
||
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions. | ||
- Deno v1.28.0 or higher, using `import Metronome from "npm:metronome"`. | ||
- Deno v1.28.0 or higher, using `import Metronome from "npm:@metronome/sdk"`. | ||
- Bun 1.0 or later. | ||
- Cloudflare Workers. | ||
- Vercel Edge Runtime. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "metronome", | ||
"name": "@metronome/sdk", | ||
"version": "0.0.1", | ||
"description": "The official TypeScript library for the Metronome API", | ||
"author": "Metronome <[email protected]>", | ||
|
@@ -62,8 +62,8 @@ | |
"./shims/web.mjs" | ||
], | ||
"imports": { | ||
"metronome": ".", | ||
"metronome/*": "./src/*" | ||
"@metronome/sdk": ".", | ||
"@metronome/sdk/*": "./src/*" | ||
}, | ||
"exports": { | ||
"./_shims/auto/*": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.