@avallon-labs/sdk 38.1.0 → 39.0.0
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 +29 -17
- package/dist/index.d.ts +4100 -2150
- package/dist/index.js +179 -116
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# @avallon/sdk
|
|
1
|
+
# @avallon-labs/sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for the Avallon API. Auto-generated from OpenAPI with custom auth utilities.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @avallon/sdk
|
|
8
|
+
npm install @avallon-labs/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
For React/SWR hooks:
|
|
12
12
|
```bash
|
|
13
|
-
npm install @avallon/sdk swr react
|
|
13
|
+
npm install @avallon-labs/sdk swr react
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
@@ -18,7 +18,7 @@ npm install @avallon/sdk swr react
|
|
|
18
18
|
### Configure
|
|
19
19
|
|
|
20
20
|
```typescript
|
|
21
|
-
import { configure } from "@avallon/sdk";
|
|
21
|
+
import { configure } from "@avallon-labs/sdk";
|
|
22
22
|
|
|
23
23
|
configure({
|
|
24
24
|
baseUrl: "https://api.avallon.ai",
|
|
@@ -28,35 +28,47 @@ configure({
|
|
|
28
28
|
});
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Response Envelope
|
|
32
|
+
|
|
33
|
+
Endpoints return the API's `{ data, message }` envelope verbatim — the payload
|
|
34
|
+
is on `data`. Paginated endpoints add `meta.total` so you can page without a
|
|
35
|
+
second request. (204 endpoints return nothing, and `getPartnerJwks` returns a
|
|
36
|
+
standards-compliant JWKS, so neither is enveloped.)
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const { data, meta } = await listArtifacts({ count: 25, offset: 50 });
|
|
40
|
+
console.log(`showing ${data.length} of ${meta.total}`);
|
|
41
|
+
```
|
|
42
|
+
|
|
31
43
|
### API Calls (Plain Fetch)
|
|
32
44
|
|
|
33
45
|
```typescript
|
|
34
|
-
import {
|
|
46
|
+
import { listVoiceAgents, createVoiceAgent } from "@avallon-labs/sdk";
|
|
35
47
|
|
|
36
48
|
// List agents
|
|
37
|
-
const
|
|
38
|
-
console.log(
|
|
49
|
+
const { data } = await listVoiceAgents();
|
|
50
|
+
console.log(data.agents);
|
|
39
51
|
|
|
40
52
|
// Create agent
|
|
41
|
-
const created = await
|
|
53
|
+
const { data: created } = await createVoiceAgent({ agent_name: "My Agent" });
|
|
42
54
|
```
|
|
43
55
|
|
|
44
56
|
### API Calls (React SWR Hooks)
|
|
45
57
|
|
|
46
58
|
```typescript
|
|
47
|
-
import {
|
|
59
|
+
import { useListVoiceAgents, useCreateVoiceAgent } from "@avallon-labs/sdk";
|
|
48
60
|
|
|
49
61
|
function AgentsList() {
|
|
50
|
-
const { data, error, isLoading } =
|
|
62
|
+
const { data, error, isLoading } = useListVoiceAgents();
|
|
51
63
|
|
|
52
64
|
if (isLoading) return <Spinner />;
|
|
53
65
|
if (error) return <Error message={error.message} />;
|
|
54
66
|
|
|
55
|
-
return <ul>{data.data.
|
|
67
|
+
return <ul>{data.data.agents.map(a => <li key={a.id}>{a.agent_name}</li>)}</ul>;
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
function CreateAgent() {
|
|
59
|
-
const { trigger, isMutating } =
|
|
71
|
+
const { trigger, isMutating } = useCreateVoiceAgent();
|
|
60
72
|
|
|
61
73
|
return (
|
|
62
74
|
<button onClick={() => trigger({ agent_name: "New Agent" })} disabled={isMutating}>
|
|
@@ -69,7 +81,7 @@ function CreateAgent() {
|
|
|
69
81
|
### OAuth Flow
|
|
70
82
|
|
|
71
83
|
```typescript
|
|
72
|
-
import { startOAuthFlow, getStoredVerifier, clearStoredVerifier,
|
|
84
|
+
import { startOAuthFlow, getStoredVerifier, clearStoredVerifier, signIn } from "@avallon-labs/sdk";
|
|
73
85
|
|
|
74
86
|
// 1. Start OAuth (redirects user)
|
|
75
87
|
const { url } = await startOAuthFlow({
|
|
@@ -80,7 +92,7 @@ window.location.href = url;
|
|
|
80
92
|
|
|
81
93
|
// 2. After redirect, exchange code for tokens
|
|
82
94
|
const verifier = getStoredVerifier();
|
|
83
|
-
const response = await
|
|
95
|
+
const response = await signIn({
|
|
84
96
|
type: "oauth",
|
|
85
97
|
code: new URLSearchParams(location.search).get("code"),
|
|
86
98
|
verifier,
|
|
@@ -88,7 +100,7 @@ const response = await postV1AuthSignIn({
|
|
|
88
100
|
clearStoredVerifier();
|
|
89
101
|
|
|
90
102
|
// 3. Store tokens and configure SDK
|
|
91
|
-
const { access_token, refresh_token, expires_at } = response.data
|
|
103
|
+
const { access_token, refresh_token, expires_at } = response.data;
|
|
92
104
|
localStorage.setItem("access_token", access_token);
|
|
93
105
|
configure({ getAccessToken: () => localStorage.getItem("access_token") });
|
|
94
106
|
```
|
|
@@ -96,10 +108,10 @@ configure({ getAccessToken: () => localStorage.getItem("access_token") });
|
|
|
96
108
|
### Error Handling
|
|
97
109
|
|
|
98
110
|
```typescript
|
|
99
|
-
import { AvallonError } from "@avallon/sdk";
|
|
111
|
+
import { AvallonError } from "@avallon-labs/sdk";
|
|
100
112
|
|
|
101
113
|
try {
|
|
102
|
-
await
|
|
114
|
+
await createVoiceAgent({ agent_name: "" });
|
|
103
115
|
} catch (e) {
|
|
104
116
|
if (e instanceof AvallonError) {
|
|
105
117
|
if (e.isValidationError()) {
|