@alvera-ai/platform-sdk 0.1.0 → 0.2.1
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 +129 -17
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +572 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +139 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +129 -2
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +129 -0
- package/dist/config.js.map +1 -0
- package/dist/generated/client.gen.d.ts.map +1 -1
- package/dist/generated/client.gen.js +1 -1
- package/dist/generated/client.gen.js.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/sdk.gen.d.ts +43 -1
- package/dist/generated/sdk.gen.d.ts.map +1 -1
- package/dist/generated/sdk.gen.js +167 -1
- package/dist/generated/sdk.gen.js.map +1 -1
- package/dist/generated/types.gen.d.ts +3864 -1408
- package/dist/generated/types.gen.d.ts.map +1 -1
- package/dist/generated/valibot.gen.d.ts +14576 -0
- package/dist/generated/valibot.gen.d.ts.map +1 -0
- package/dist/generated/valibot.gen.js +3090 -0
- package/dist/generated/valibot.gen.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -5
package/README.md
CHANGED
|
@@ -16,20 +16,26 @@ pnpm add @alvera-ai/platform-sdk
|
|
|
16
16
|
## Quick start
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
|
-
import { createPlatformApi } from '@alvera-ai/platform-sdk';
|
|
19
|
+
import { createPlatformApi, createSession } from '@alvera-ai/platform-sdk';
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const baseUrl = 'https://admin.alvera.ai';
|
|
22
|
+
|
|
23
|
+
// 1. Exchange credentials for a session token
|
|
24
|
+
const session = await createSession({
|
|
25
|
+
baseUrl,
|
|
26
|
+
email: process.env.ALVERA_EMAIL!,
|
|
27
|
+
password: process.env.ALVERA_PASSWORD!,
|
|
28
|
+
tenantSlug: 'acme',
|
|
24
29
|
});
|
|
25
30
|
|
|
26
|
-
//
|
|
31
|
+
// 2. Build the API client with that token
|
|
32
|
+
const api = createPlatformApi({ baseUrl, sessionToken: session.sessionToken });
|
|
33
|
+
|
|
34
|
+
// 3. Use it
|
|
27
35
|
await api.ping();
|
|
28
36
|
|
|
29
|
-
// List datalakes for a tenant
|
|
30
37
|
const { data: datalakes } = await api.datalakes.list('acme');
|
|
31
38
|
|
|
32
|
-
// Create a data source
|
|
33
39
|
const { data: ds } = await api.dataSources.create('acme', 'acme-health', {
|
|
34
40
|
name: 'Acme EMR',
|
|
35
41
|
uri: 'our-emr:acme',
|
|
@@ -38,7 +44,6 @@ const { data: ds } = await api.dataSources.create('acme', 'acme-health', {
|
|
|
38
44
|
is_default: true,
|
|
39
45
|
});
|
|
40
46
|
|
|
41
|
-
// Attach a tool to the data source
|
|
42
47
|
const { data: tool } = await api.tools.create('acme', {
|
|
43
48
|
name: 'Acme Manual Upload',
|
|
44
49
|
intent: 'data_exchange',
|
|
@@ -51,20 +56,46 @@ const { data: tool } = await api.tools.create('acme', {
|
|
|
51
56
|
|
|
52
57
|
## Authentication
|
|
53
58
|
|
|
54
|
-
The SDK
|
|
55
|
-
|
|
59
|
+
The SDK uses **session-based** auth.
|
|
60
|
+
|
|
61
|
+
1. Call `createSession({ baseUrl, email, password, tenantSlug })` with your
|
|
62
|
+
Alvera login credentials and the tenant you want to operate on.
|
|
63
|
+
2. The returned `sessionToken` is a Bearer token, valid for 24 hours by
|
|
64
|
+
default (override with `expiresIn`, max 30 days).
|
|
65
|
+
3. Pass the token into `createPlatformApi({ baseUrl, sessionToken })`.
|
|
66
|
+
4. When done, optionally call `revokeSession()` to invalidate the token.
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { createSession, createPlatformApi, revokeSession } from '@alvera-ai/platform-sdk';
|
|
70
|
+
|
|
71
|
+
const session = await createSession({
|
|
72
|
+
baseUrl, email, password, tenantSlug: 'acme', expiresIn: 3600,
|
|
73
|
+
});
|
|
74
|
+
const api = createPlatformApi({ baseUrl, sessionToken: session.sessionToken });
|
|
75
|
+
// ... use api ...
|
|
76
|
+
await revokeSession();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`session.expiresAt` is an ISO-8601 timestamp — check it before long-running
|
|
80
|
+
work and re-authenticate if needed.
|
|
56
81
|
|
|
57
82
|
## Resources
|
|
58
83
|
|
|
59
84
|
| Resource | Operations |
|
|
60
85
|
|-------------------------|---------------------------------------------|
|
|
61
|
-
| `ping`
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
86
|
+
| `ping` | health check |
|
|
87
|
+
| `sessions` | `verify` |
|
|
88
|
+
| `datasets` | `search` |
|
|
89
|
+
| `datalakes` | `list`, `get`, `create` |
|
|
90
|
+
| `dataSources` | `list`, `create`, `update` |
|
|
91
|
+
| `tools` | `list`, `get`, `create`, `update`, `delete` |
|
|
92
|
+
| `genericTables` | `list`, `create` |
|
|
93
|
+
| `actionStatusUpdaters` | `list`, `create`, `update` |
|
|
94
|
+
| `aiAgents` | `list`, `get`, `create`, `update`, `delete` |
|
|
95
|
+
| `connectedApps` | `list`, `get`, `create`, `update`, `syncRoutes`, `resolvePage`, `updateMessageTracking` |
|
|
96
|
+
| `dataActivationClients` | `ingest`, `ingestFile`, `createUploadLink` |
|
|
97
|
+
| `mdm` | `verify` |
|
|
98
|
+
| `workflows` | `execute` |
|
|
68
99
|
|
|
69
100
|
Tenant and datalake provisioning are performed by Alvera admins — contact your
|
|
70
101
|
representative to onboard a new tenant.
|
|
@@ -82,6 +113,87 @@ try {
|
|
|
82
113
|
}
|
|
83
114
|
```
|
|
84
115
|
|
|
116
|
+
## CLI
|
|
117
|
+
|
|
118
|
+
The package ships a companion CLI (`alvera`) for ad-hoc calls against the
|
|
119
|
+
platform API. Install the package (globally, or via `npx`) and authenticate
|
|
120
|
+
once — subsequent commands reuse the stored session.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Run without installing
|
|
124
|
+
npx @alvera-ai/platform-sdk --help
|
|
125
|
+
|
|
126
|
+
# Or install globally
|
|
127
|
+
npm install -g @alvera-ai/platform-sdk
|
|
128
|
+
alvera --help
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Configuration
|
|
132
|
+
|
|
133
|
+
`alvera` stores state under `~/.alvera-ai/`, AWS CLI–style:
|
|
134
|
+
|
|
135
|
+
| File | Purpose |
|
|
136
|
+
|-----------------------------|---------------------------------------------------|
|
|
137
|
+
| `~/.alvera-ai/config` | Per-profile defaults (base URL, tenant, email) |
|
|
138
|
+
| `~/.alvera-ai/credentials` | Per-profile session token and expiration (0600) |
|
|
139
|
+
|
|
140
|
+
Both files are INI. The default profile is `[default]`; additional profiles
|
|
141
|
+
live under `[profile <name>]` in `config` and `[<name>]` in `credentials`.
|
|
142
|
+
|
|
143
|
+
Every command accepts `--profile <name>`. Environment variables
|
|
144
|
+
(`ALVERA_PROFILE`, `ALVERA_BASE_URL`, `ALVERA_TENANT`, `ALVERA_EMAIL`,
|
|
145
|
+
`ALVERA_PASSWORD`, `ALVERA_SESSION_TOKEN`) take precedence over file values.
|
|
146
|
+
|
|
147
|
+
### Getting started
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
alvera configure # set base URL + default tenant
|
|
151
|
+
alvera login --email me@acme.com --tenant acme
|
|
152
|
+
alvera ping
|
|
153
|
+
alvera datalakes list
|
|
154
|
+
alvera tools create --body-file tool.json
|
|
155
|
+
alvera logout
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Multiple environments via profiles:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
alvera --profile staging login --base-url https://admin.staging.alvera.ai --tenant acme
|
|
162
|
+
alvera --profile staging datalakes list
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Command surface
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
alvera configure
|
|
169
|
+
alvera login [--email] [--password] [--tenant] [--base-url] [--expires-in]
|
|
170
|
+
alvera logout
|
|
171
|
+
alvera whoami
|
|
172
|
+
alvera ping
|
|
173
|
+
|
|
174
|
+
alvera datalakes list | get <id> | create
|
|
175
|
+
alvera data-sources list <datalake> | create <datalake> | update <datalake> <id>
|
|
176
|
+
alvera tools list | get <id> | create | update <id> | delete <id>
|
|
177
|
+
alvera generic-tables list <datalake> | create <datalake>
|
|
178
|
+
alvera action-status-updaters list | create | update <id>
|
|
179
|
+
alvera ai-agents list <datalake> | get <datalake> <id> | create <datalake>
|
|
180
|
+
| update <datalake> <id> | delete <datalake> <id>
|
|
181
|
+
alvera sessions-verify
|
|
182
|
+
alvera datasets search <dataset> [--datalake-id] [--page] [--page-size]
|
|
183
|
+
alvera connected-apps list <datalake> | get <datalake> <id> | create <datalake>
|
|
184
|
+
| update <datalake> <id> | sync-routes <datalake> <id>
|
|
185
|
+
| resolve-page <slug> | update-message-tracking <slug>
|
|
186
|
+
alvera data-activation-clients ingest <slug> | ingest-file <slug> <key>
|
|
187
|
+
| upload-link <slug> <filename> [--content-type]
|
|
188
|
+
alvera mdm verify <datalake>
|
|
189
|
+
alvera workflows execute <workflow-slug>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
All `create` / `update` commands require `--body '<json>'` or `--body-file <path>`
|
|
193
|
+
(use `-` for stdin). A tenant positional argument is optional when the profile
|
|
194
|
+
has a default tenant configured. Output is pretty-printed JSON on stdout;
|
|
195
|
+
status messages and prompts go to stderr so responses stay pipeable.
|
|
196
|
+
|
|
85
197
|
## Regenerating the typed client
|
|
86
198
|
|
|
87
199
|
The typed client is generated from the live OpenAPI spec at
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|