@band-ai/rest-client 0.0.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +243 -0
  2. package/package.json +66 -0
  3. package/reference.md +4235 -0
package/README.md ADDED
@@ -0,0 +1,243 @@
1
+ # Thenvoi TypeScript Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fthenvoi%2Ffern-javascript-sdk)
4
+ [![npm shield](https://img.shields.io/npm/v/@thenvoi/rest-client)](https://www.npmjs.com/package/@thenvoi/rest-client)
5
+
6
+ The Thenvoi TypeScript library provides convenient access to the Thenvoi APIs from TypeScript.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ npm i -s @thenvoi/rest-client
12
+ ```
13
+
14
+ ## Reference
15
+
16
+ A full reference for this library is available [here](https://github.com/thenvoi/fern-javascript-sdk/blob/HEAD/./reference.md).
17
+
18
+ ## Usage
19
+
20
+ Instantiate and use the client with the following:
21
+
22
+ ```typescript
23
+ import { ThenvoiClient } from "@thenvoi/rest-client";
24
+
25
+ const client = new ThenvoiClient({ apiKey: "YOUR_API_KEY" });
26
+ await client.agentApiContacts.respondToAgentContactRequest({
27
+ action: "approve"
28
+ });
29
+ ```
30
+
31
+ ## Request And Response Types
32
+
33
+ The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
34
+ following namespace:
35
+
36
+ ```typescript
37
+ import { Thenvoi } from "@thenvoi/rest-client";
38
+
39
+ const request: Thenvoi.RespondToAgentContactRequestRequest = {
40
+ ...
41
+ };
42
+ ```
43
+
44
+ ## Exception Handling
45
+
46
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
47
+ will be thrown.
48
+
49
+ ```typescript
50
+ import { ThenvoiError } from "@thenvoi/rest-client";
51
+
52
+ try {
53
+ await client.agentApiContacts.respondToAgentContactRequest(...);
54
+ } catch (err) {
55
+ if (err instanceof ThenvoiError) {
56
+ console.log(err.statusCode);
57
+ console.log(err.message);
58
+ console.log(err.body);
59
+ console.log(err.rawResponse);
60
+ }
61
+ }
62
+ ```
63
+
64
+ ## Advanced
65
+
66
+ ### Additional Headers
67
+
68
+ If you would like to send additional headers as part of the request, use the `headers` request option.
69
+
70
+ ```typescript
71
+ const response = await client.agentApiContacts.respondToAgentContactRequest(..., {
72
+ headers: {
73
+ 'X-Custom-Header': 'custom value'
74
+ }
75
+ });
76
+ ```
77
+
78
+ ### Additional Query String Parameters
79
+
80
+ If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
81
+
82
+ ```typescript
83
+ const response = await client.agentApiContacts.respondToAgentContactRequest(..., {
84
+ queryParams: {
85
+ 'customQueryParamKey': 'custom query param value'
86
+ }
87
+ });
88
+ ```
89
+
90
+ ### Retries
91
+
92
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
93
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
94
+ retry limit (default: 2).
95
+
96
+ A request is deemed retryable when any of the following HTTP status codes is returned:
97
+
98
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
99
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
100
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
101
+
102
+ Use the `maxRetries` request option to configure this behavior.
103
+
104
+ ```typescript
105
+ const response = await client.agentApiContacts.respondToAgentContactRequest(..., {
106
+ maxRetries: 0 // override maxRetries at the request level
107
+ });
108
+ ```
109
+
110
+ ### Timeouts
111
+
112
+ The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
113
+
114
+ ```typescript
115
+ const response = await client.agentApiContacts.respondToAgentContactRequest(..., {
116
+ timeoutInSeconds: 30 // override timeout to 30s
117
+ });
118
+ ```
119
+
120
+ ### Aborting Requests
121
+
122
+ The SDK allows users to abort requests at any point by passing in an abort signal.
123
+
124
+ ```typescript
125
+ const controller = new AbortController();
126
+ const response = await client.agentApiContacts.respondToAgentContactRequest(..., {
127
+ abortSignal: controller.signal
128
+ });
129
+ controller.abort(); // aborts the request
130
+ ```
131
+
132
+ ### Access Raw Response Data
133
+
134
+ The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method.
135
+ The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
136
+
137
+ ```typescript
138
+ const { data, rawResponse } = await client.agentApiContacts.respondToAgentContactRequest(...).withRawResponse();
139
+
140
+ console.log(data);
141
+ console.log(rawResponse.headers['X-My-Header']);
142
+ ```
143
+
144
+ ### Logging
145
+
146
+ The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options.
147
+
148
+ ```typescript
149
+ import { ThenvoiClient, logging } from "@thenvoi/rest-client";
150
+
151
+ const client = new ThenvoiClient({
152
+ ...
153
+ logging: {
154
+ level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info
155
+ logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger
156
+ silent: false, // defaults to true, set to false to enable logging
157
+ }
158
+ });
159
+ ```
160
+ The `logging` object can have the following properties:
161
+ - `level`: The log level to use. Defaults to `logging.LogLevel.Info`.
162
+ - `logger`: The logger to use. Defaults to a `logging.ConsoleLogger`.
163
+ - `silent`: Whether to silence the logger. Defaults to `true`.
164
+
165
+ The `level` property can be one of the following values:
166
+ - `logging.LogLevel.Debug`
167
+ - `logging.LogLevel.Info`
168
+ - `logging.LogLevel.Warn`
169
+ - `logging.LogLevel.Error`
170
+
171
+ To provide a custom logger, you can pass in an object that implements the `logging.ILogger` interface.
172
+
173
+ <details>
174
+ <summary>Custom logger examples</summary>
175
+
176
+ Here's an example using the popular `winston` logging library.
177
+ ```ts
178
+ import winston from 'winston';
179
+
180
+ const winstonLogger = winston.createLogger({...});
181
+
182
+ const logger: logging.ILogger = {
183
+ debug: (msg, ...args) => winstonLogger.debug(msg, ...args),
184
+ info: (msg, ...args) => winstonLogger.info(msg, ...args),
185
+ warn: (msg, ...args) => winstonLogger.warn(msg, ...args),
186
+ error: (msg, ...args) => winstonLogger.error(msg, ...args),
187
+ };
188
+ ```
189
+
190
+ Here's an example using the popular `pino` logging library.
191
+
192
+ ```ts
193
+ import pino from 'pino';
194
+
195
+ const pinoLogger = pino({...});
196
+
197
+ const logger: logging.ILogger = {
198
+ debug: (msg, ...args) => pinoLogger.debug(args, msg),
199
+ info: (msg, ...args) => pinoLogger.info(args, msg),
200
+ warn: (msg, ...args) => pinoLogger.warn(args, msg),
201
+ error: (msg, ...args) => pinoLogger.error(args, msg),
202
+ };
203
+ ```
204
+ </details>
205
+
206
+
207
+ ### Runtime Compatibility
208
+
209
+
210
+ The SDK works in the following runtimes:
211
+
212
+
213
+
214
+ - Node.js 18+
215
+ - Vercel
216
+ - Cloudflare Workers
217
+ - Deno v1.25+
218
+ - Bun 1.0+
219
+ - React Native
220
+
221
+ ### Customizing Fetch Client
222
+
223
+ The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
224
+ unsupported environment, this provides a way for you to break glass and ensure the SDK works.
225
+
226
+ ```typescript
227
+ import { ThenvoiClient } from "@thenvoi/rest-client";
228
+
229
+ const client = new ThenvoiClient({
230
+ ...
231
+ fetcher: // provide your implementation here
232
+ });
233
+ ```
234
+
235
+ ## Contributing
236
+
237
+ While we value open-source contributions to this SDK, this library is generated programmatically.
238
+ Additions made directly to this library would have to be moved over to our generation code,
239
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
240
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
241
+ an issue first to discuss with us!
242
+
243
+ On the other hand, contributions to the README are always very welcome!
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@band-ai/rest-client",
3
+ "version": "0.0.113",
4
+ "private": false,
5
+ "repository": "github:thenvoi/fern-javascript-sdk",
6
+ "type": "commonjs",
7
+ "main": "./dist/cjs/index.js",
8
+ "module": "./dist/esm/index.mjs",
9
+ "types": "./dist/cjs/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/cjs/index.d.ts",
13
+ "import": {
14
+ "types": "./dist/esm/index.d.mts",
15
+ "default": "./dist/esm/index.mjs"
16
+ },
17
+ "require": {
18
+ "types": "./dist/cjs/index.d.ts",
19
+ "default": "./dist/cjs/index.js"
20
+ },
21
+ "default": "./dist/cjs/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "reference.md",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "scripts": {
32
+ "format": "biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
33
+ "format:check": "biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
34
+ "lint": "biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
35
+ "lint:fix": "biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
36
+ "check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
37
+ "check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
38
+ "build": "pnpm build:cjs && pnpm build:esm",
39
+ "build:cjs": "tsc --project ./tsconfig.cjs.json",
40
+ "build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm",
41
+ "test": "vitest",
42
+ "test:unit": "vitest --project unit",
43
+ "test:wire": "vitest --project wire"
44
+ },
45
+ "dependencies": {},
46
+ "devDependencies": {
47
+ "webpack": "^5.97.1",
48
+ "ts-loader": "^9.5.1",
49
+ "vitest": "^3.2.4",
50
+ "msw": "2.11.2",
51
+ "@types/node": "^18.19.70",
52
+ "typescript": "~5.7.2",
53
+ "@biomejs/biome": "2.3.1"
54
+ },
55
+ "browser": {
56
+ "fs": false,
57
+ "os": false,
58
+ "path": false,
59
+ "stream": false
60
+ },
61
+ "packageManager": "pnpm@10.20.0",
62
+ "engines": {
63
+ "node": ">=18.0.0"
64
+ },
65
+ "sideEffects": false
66
+ }