@open-connector/sdk 1.0.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/LICENSE +661 -0
- package/README.md +72 -0
- package/dist/index-96n68fp1.d.cts +1495 -0
- package/dist/index-96n68fp1.d.cts.map +1 -0
- package/dist/index-BXEKBblV.d.ts +1495 -0
- package/dist/index-BXEKBblV.d.ts.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/src-19LKPmdg.cjs +118 -0
- package/dist/src-19LKPmdg.cjs.map +1 -0
- package/dist/src-CvNjrj1s.js +89 -0
- package/dist/src-CvNjrj1s.js.map +1 -0
- package/dist/testing.cjs +7 -0
- package/dist/testing.d.cts +2 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2 -0
- package/package.json +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @open-connector/sdk
|
|
2
|
+
|
|
3
|
+
The first-party TypeScript SDK for Open Connector — a fully-typed
|
|
4
|
+
[`@orpc/client`](https://orpc.unnoq.com) over the **native** API surface
|
|
5
|
+
(`/api/v1`). It is **not** `@composio/client` and does not speak the v3.1 compat
|
|
6
|
+
wire; it targets our own oRPC router directly.
|
|
7
|
+
|
|
8
|
+
## Why this design
|
|
9
|
+
|
|
10
|
+
The client type is **inferred from the shared native oRPC contract**
|
|
11
|
+
(`ContractRouterClient<NativeContract>`) — there is no codegen and no drift. Add
|
|
12
|
+
a procedure to the contract and it appears here, fully typed. The publish build
|
|
13
|
+
bundles those declarations, so SDK consumers never depend on private monorepo
|
|
14
|
+
packages. This is the reference implementation that the `oc` CLI is built on.
|
|
15
|
+
|
|
16
|
+
Other languages are generated from the committed OpenAPI spec
|
|
17
|
+
(`packages/api/openapi/native.json`) — the TS SDK does not need it.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createClient } from "@open-connector/sdk";
|
|
23
|
+
|
|
24
|
+
const oc = createClient({
|
|
25
|
+
baseUrl: "http://localhost:3000", // server root; the SDK appends /api/v1
|
|
26
|
+
apiKey: process.env.OC_API_KEY!, // sent as x-api-key
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Discover
|
|
30
|
+
const toolkits = await oc.listToolkits({ search: "git" });
|
|
31
|
+
const tools = await oc.listTools({ toolkit: "github" });
|
|
32
|
+
|
|
33
|
+
// Authorize (BYO or managed)
|
|
34
|
+
const cfg = await oc.createAuthConfig({ slug: "github" });
|
|
35
|
+
|
|
36
|
+
// Execute a named tool
|
|
37
|
+
const res = await oc.executeTool({
|
|
38
|
+
slug: "GITHUB_ISSUES_CREATE",
|
|
39
|
+
userId: "user-1",
|
|
40
|
+
arguments: { owner: "acme", repo: "app", title: "Bug" },
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### OAuth connect helper
|
|
45
|
+
|
|
46
|
+
`createClient` exposes the raw procedures; for the OAuth round-trip the SDK adds
|
|
47
|
+
a small wait/poll loop (the only logic it owns), mirroring Composio's
|
|
48
|
+
`waitForConnection`:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { connectOAuth } from "@open-connector/sdk";
|
|
52
|
+
|
|
53
|
+
const result = await connectOAuth(oc, {
|
|
54
|
+
slug: "github",
|
|
55
|
+
userId: "user-1",
|
|
56
|
+
onRedirect: (url) => console.error("authorize at:", url),
|
|
57
|
+
// waitForActive: true (default) → resolves once the connection is active
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Surface
|
|
62
|
+
|
|
63
|
+
`listToolkits` · `getToolkit` · `listTools` · `getTool` · `executeTool` ·
|
|
64
|
+
`createAuthConfig` · `listAuthConfigs` · `getAuthConfig` · `initiate` ·
|
|
65
|
+
`connect` · `proxy` · `listConnections` · `getConnection` ·
|
|
66
|
+
`refreshConnection` · `revokeConnection` · `deleteConnection`
|
|
67
|
+
· `listTriggerTypes` · `getTriggerType` · `listTriggerInstances`
|
|
68
|
+
· `upsertTriggerInstance` · `setTriggerInstanceStatus` · `deleteTriggerInstance`
|
|
69
|
+
|
|
70
|
+
Plus helpers: `createClient`, `connectOAuth`, `waitForConnection` (throws flat
|
|
71
|
+
`EvlogError` with `code: "connect.failed"` on terminal failure). The SDK derives
|
|
72
|
+
the native `/api/v1` endpoint from `baseUrl`; callers do not need URL helpers.
|