tevrocsdk 0.1.0 → 0.1.2
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 +189 -0
- package/package.json +7 -1
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Tevroc SDK
|
|
2
|
+
|
|
3
|
+
JavaScript SDK for the `tevroc-api`
|
|
4
|
+
|
|
5
|
+
Supports:
|
|
6
|
+
- ESM (import)
|
|
7
|
+
- UMD (browser `<script>`)
|
|
8
|
+
- CDN usage (unpkg/jsdelivr)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
### npm / ESM
|
|
15
|
+
```bash
|
|
16
|
+
npm install tevrocsdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Browser (UMD / CDN)
|
|
20
|
+
Option 1: Local file
|
|
21
|
+
``` html
|
|
22
|
+
<script src="./tevroc-sdk.umd.js"></script>
|
|
23
|
+
<script>
|
|
24
|
+
const tevroc = Tevroc.createClient({
|
|
25
|
+
baseUrl: "https://your-worker.example.workers.dev"
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Option 2: CDN (recommended)
|
|
31
|
+
```html
|
|
32
|
+
<script src="https://unpkg.com/tevrocsdk/dist/tevroc-sdk.umd.js"></script>
|
|
33
|
+
<script>
|
|
34
|
+
const tevroc = Tevroc.createClient({
|
|
35
|
+
baseUrl: "https://your-worker.example.workers.dev"
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Create a client
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { createClient } from "tevrocsdk";
|
|
45
|
+
|
|
46
|
+
const tevroc = createClient({
|
|
47
|
+
baseUrl: "http://localhost:8787",
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
You can also pass an existing token:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const tevroc = createClient({
|
|
55
|
+
baseUrl: "https://your-worker.example.workers.dev",
|
|
56
|
+
token: localStorage.getItem("tevroc_token"),
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Auth
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const { token, user } = await tevroc.auth.login({
|
|
64
|
+
email: "ada@example.com",
|
|
65
|
+
password: "correct horse battery staple",
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// The SDK stores the token on the client after login/register.
|
|
69
|
+
const me = await tevroc.auth.me();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Entities
|
|
73
|
+
|
|
74
|
+
Entities are dynamic, like the Base44 SDK.
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
const created = await tevroc.entities.Project.create({
|
|
78
|
+
name: "Launch site",
|
|
79
|
+
status: "active",
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const projects = await tevroc.entities.Project.list({ limit: 20 });
|
|
83
|
+
|
|
84
|
+
const filtered = await tevroc.entities.Project.query({
|
|
85
|
+
filter: { status: "active" },
|
|
86
|
+
limit: 10,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
await tevroc.entities.Project.update(created.data.id, { status: "done" });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Available methods:
|
|
93
|
+
|
|
94
|
+
- `list({ limit, offset })`
|
|
95
|
+
- `get(id)`
|
|
96
|
+
- `create(record)`
|
|
97
|
+
- `update(id, patch)`
|
|
98
|
+
- `delete(id)`
|
|
99
|
+
- `query({ filter, limit })`
|
|
100
|
+
- `bulkCreate(records)`
|
|
101
|
+
- `bulkUpdate(records)`
|
|
102
|
+
- `bulkDelete(ids)`
|
|
103
|
+
- `import(records)`
|
|
104
|
+
|
|
105
|
+
## Functions
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
await tevroc.functions.invoke("ping", { hello: "world" });
|
|
109
|
+
|
|
110
|
+
// Shorthand:
|
|
111
|
+
await tevroc.functions.ping({ hello: "world" });
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Core integrations
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
await tevroc.integrations.Core.InvokeLLM({
|
|
118
|
+
prompt: "Write a two-line launch checklist.",
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
await tevroc.integrations.Core.SendEmail({
|
|
122
|
+
to: "ada@example.com",
|
|
123
|
+
subject: "Hello",
|
|
124
|
+
text: "From Tevroc",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
await tevroc.integrations.Core.UploadFile(file, {
|
|
128
|
+
filename: "report.pdf",
|
|
129
|
+
contentType: "application/pdf",
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Agents
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
const conversation = await tevroc.agents.Support.createConversation({
|
|
137
|
+
title: "Onboarding",
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
await tevroc.agents.Support.addMessage(conversation.data.id, {
|
|
141
|
+
role: "user",
|
|
142
|
+
content: "Help me configure my workspace",
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const messages = await tevroc.agents.Support.listMessages(conversation.data.id);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Connectors, logs, SSO, and custom integrations
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
await tevroc.connectors.list();
|
|
152
|
+
await tevroc.connectors.connect("slack", { config: { teamId: "T123" } });
|
|
153
|
+
await tevroc.connectors.status("slack");
|
|
154
|
+
|
|
155
|
+
await tevroc.logs.create({
|
|
156
|
+
level: "info",
|
|
157
|
+
message: "User opened dashboard",
|
|
158
|
+
context: { source: "web" },
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
await tevroc.customIntegrations.example.echo({ ok: true });
|
|
162
|
+
await tevroc.sso.accessToken({ code: "provider-code" });
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Raw requests
|
|
166
|
+
|
|
167
|
+
Use `request` for worker routes that do not have a convenience wrapper yet.
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
const health = await tevroc.request("/health", { auth: false });
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Error handling
|
|
174
|
+
|
|
175
|
+
API errors throw `TevrocError` with `status`, `code`, and `details`.
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
import { TevrocError } from "tevrocsdk";
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
await tevroc.auth.me();
|
|
182
|
+
} catch (error) {
|
|
183
|
+
if (error instanceof TevrocError && error.status === 401) {
|
|
184
|
+
// Ask the user to log in.
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tevrocsdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Base44-style JavaScript SDK for the Tevroc Worker API.",
|
|
5
5
|
"main": "./tevroc-sdk.umd.js",
|
|
6
6
|
"module": "./tevroc-sdk.esm.js",
|
|
7
|
+
|
|
8
|
+
"keywords": [
|
|
9
|
+
"tevroc",
|
|
10
|
+
"sdk",
|
|
11
|
+
"worker"
|
|
12
|
+
],
|
|
7
13
|
"license": "MIT"
|
|
8
14
|
}
|