@airweave/sdk 0.7.2 → 0.7.3
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.
- package/README.md +199 -0
- package/dist/cjs/Client.js +2 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.mjs +2 -2
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# Airweave TypeScript Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fairweave-ai%2Ftypescript-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/@airweave/sdk)
|
|
5
|
+
|
|
6
|
+
The Airweave TypeScript library provides convenient access to the Airweave APIs from TypeScript.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Reference](#reference)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Request and Response Types](#request-and-response-types)
|
|
14
|
+
- [Exception Handling](#exception-handling)
|
|
15
|
+
- [Advanced](#advanced)
|
|
16
|
+
- [Additional Headers](#additional-headers)
|
|
17
|
+
- [Additional Query String Parameters](#additional-query-string-parameters)
|
|
18
|
+
- [Retries](#retries)
|
|
19
|
+
- [Timeouts](#timeouts)
|
|
20
|
+
- [Aborting Requests](#aborting-requests)
|
|
21
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
22
|
+
- [Runtime Compatibility](#runtime-compatibility)
|
|
23
|
+
- [Contributing](#contributing)
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm i -s @airweave/sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Reference
|
|
32
|
+
|
|
33
|
+
A full reference for this library is available [here](https://github.com/airweave-ai/typescript-sdk/blob/HEAD/./reference.md).
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Instantiate and use the client with the following:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { AirweaveSDKClient } from "@airweave/sdk";
|
|
41
|
+
|
|
42
|
+
const client = new AirweaveSDKClient({
|
|
43
|
+
apiKey: "YOUR_API_KEY",
|
|
44
|
+
frameworkName: "YOUR_FRAMEWORK_NAME",
|
|
45
|
+
frameworkVersion: "YOUR_FRAMEWORK_VERSION",
|
|
46
|
+
});
|
|
47
|
+
await client.collections.create({
|
|
48
|
+
name: "Finance Data",
|
|
49
|
+
readable_id: "finance-data-reports",
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Request and Response Types
|
|
54
|
+
|
|
55
|
+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
|
|
56
|
+
following namespace:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { AirweaveSDK } from "@airweave/sdk";
|
|
60
|
+
|
|
61
|
+
const request: AirweaveSDK.ListCollectionsGetRequest = {
|
|
62
|
+
...
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Exception Handling
|
|
67
|
+
|
|
68
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
69
|
+
will be thrown.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { AirweaveSDKError } from "@airweave/sdk";
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
await client.collections.create(...);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
if (err instanceof AirweaveSDKError) {
|
|
78
|
+
console.log(err.statusCode);
|
|
79
|
+
console.log(err.message);
|
|
80
|
+
console.log(err.body);
|
|
81
|
+
console.log(err.rawResponse);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Advanced
|
|
87
|
+
|
|
88
|
+
### Additional Headers
|
|
89
|
+
|
|
90
|
+
If you would like to send additional headers as part of the request, use the `headers` request option.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
const response = await client.collections.create(..., {
|
|
94
|
+
headers: {
|
|
95
|
+
'X-Custom-Header': 'custom value'
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Additional Query String Parameters
|
|
101
|
+
|
|
102
|
+
If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const response = await client.collections.create(..., {
|
|
106
|
+
queryParams: {
|
|
107
|
+
'customQueryParamKey': 'custom query param value'
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Retries
|
|
113
|
+
|
|
114
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
115
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
116
|
+
retry limit (default: 2).
|
|
117
|
+
|
|
118
|
+
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
119
|
+
|
|
120
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
121
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
122
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
123
|
+
|
|
124
|
+
Use the `maxRetries` request option to configure this behavior.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
const response = await client.collections.create(..., {
|
|
128
|
+
maxRetries: 0 // override maxRetries at the request level
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Timeouts
|
|
133
|
+
|
|
134
|
+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const response = await client.collections.create(..., {
|
|
138
|
+
timeoutInSeconds: 30 // override timeout to 30s
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Aborting Requests
|
|
143
|
+
|
|
144
|
+
The SDK allows users to abort requests at any point by passing in an abort signal.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const controller = new AbortController();
|
|
148
|
+
const response = await client.collections.create(..., {
|
|
149
|
+
abortSignal: controller.signal
|
|
150
|
+
});
|
|
151
|
+
controller.abort(); // aborts the request
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Access Raw Response Data
|
|
155
|
+
|
|
156
|
+
The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method.
|
|
157
|
+
The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
const { data, rawResponse } = await client.collections.create(...).withRawResponse();
|
|
161
|
+
|
|
162
|
+
console.log(data);
|
|
163
|
+
console.log(rawResponse.headers['X-My-Header']);
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Runtime Compatibility
|
|
167
|
+
|
|
168
|
+
The SDK works in the following runtimes:
|
|
169
|
+
|
|
170
|
+
- Node.js 18+
|
|
171
|
+
- Vercel
|
|
172
|
+
- Cloudflare Workers
|
|
173
|
+
- Deno v1.25+
|
|
174
|
+
- Bun 1.0+
|
|
175
|
+
- React Native
|
|
176
|
+
|
|
177
|
+
### Customizing Fetch Client
|
|
178
|
+
|
|
179
|
+
The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
|
|
180
|
+
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { AirweaveSDKClient } from "@airweave/sdk";
|
|
184
|
+
|
|
185
|
+
const client = new AirweaveSDKClient({
|
|
186
|
+
...
|
|
187
|
+
fetcher: // provide your implementation here
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Contributing
|
|
192
|
+
|
|
193
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
194
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
195
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
196
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
197
|
+
an issue first to discuss with us!
|
|
198
|
+
|
|
199
|
+
On the other hand, contributions to the README are always very welcome!
|
package/dist/cjs/Client.js
CHANGED
|
@@ -49,8 +49,8 @@ class AirweaveSDKClient {
|
|
|
49
49
|
"X-Framework-Version": _options === null || _options === void 0 ? void 0 : _options.frameworkVersion,
|
|
50
50
|
"X-Fern-Language": "JavaScript",
|
|
51
51
|
"X-Fern-SDK-Name": "@airweave/sdk",
|
|
52
|
-
"X-Fern-SDK-Version": "v0.7.
|
|
53
|
-
"User-Agent": "@airweave/sdk/v0.7.
|
|
52
|
+
"X-Fern-SDK-Version": "v0.7.3",
|
|
53
|
+
"User-Agent": "@airweave/sdk/v0.7.3",
|
|
54
54
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
55
55
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
56
56
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "v0.7.
|
|
1
|
+
export declare const SDK_VERSION = "v0.7.3";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.mjs
CHANGED
|
@@ -13,8 +13,8 @@ export class AirweaveSDKClient {
|
|
|
13
13
|
"X-Framework-Version": _options === null || _options === void 0 ? void 0 : _options.frameworkVersion,
|
|
14
14
|
"X-Fern-Language": "JavaScript",
|
|
15
15
|
"X-Fern-SDK-Name": "@airweave/sdk",
|
|
16
|
-
"X-Fern-SDK-Version": "v0.7.
|
|
17
|
-
"User-Agent": "@airweave/sdk/v0.7.
|
|
16
|
+
"X-Fern-SDK-Version": "v0.7.3",
|
|
17
|
+
"User-Agent": "@airweave/sdk/v0.7.3",
|
|
18
18
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
19
19
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
20
20
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "v0.7.
|
|
1
|
+
export declare const SDK_VERSION = "v0.7.3";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "v0.7.
|
|
1
|
+
export const SDK_VERSION = "v0.7.3";
|