@anchrd/colab-sdk 0.0.0-stage → 0.1.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 +65 -2
- package/dist/actions/actions.d.ts +810 -0
- package/dist/actions/actions.js +177 -0
- package/dist/admin-mode.d.ts +2 -0
- package/dist/admin-mode.js +5 -0
- package/dist/apps/apps.d.ts +108 -0
- package/dist/apps/apps.js +73 -0
- package/dist/archive/archive.d.ts +25 -0
- package/dist/archive/archive.js +27 -0
- package/dist/auth/auth.d.ts +27 -0
- package/dist/auth/auth.js +22 -0
- package/dist/authorization/authorization.d.ts +36 -0
- package/dist/authorization/authorization.js +23 -0
- package/dist/boards/boards.d.ts +612 -0
- package/dist/boards/boards.js +289 -0
- package/dist/columns/columns.d.ts +28 -0
- package/dist/columns/columns.js +28 -0
- package/dist/connections/connections.d.ts +149 -0
- package/dist/connections/connections.js +74 -0
- package/dist/connectors/connectors.d.ts +148 -0
- package/dist/connectors/connectors.js +83 -0
- package/dist/dashboards/dashboards.d.ts +221 -0
- package/dist/dashboards/dashboards.js +520 -0
- package/dist/directory/directory.d.ts +20 -0
- package/dist/directory/directory.js +18 -0
- package/dist/documents/documents.d.ts +61 -0
- package/dist/documents/documents.js +58 -0
- package/dist/error/error.d.ts +34 -0
- package/dist/error/error.js +30 -0
- package/dist/events/events.d.ts +104 -0
- package/dist/events/events.js +69 -0
- package/dist/files/files.d.ts +60 -0
- package/dist/files/files.js +139 -0
- package/dist/functions/functions.d.ts +26 -0
- package/dist/functions/functions.js +28 -0
- package/dist/grammar/grammar.d.ts +62 -0
- package/dist/grammar/grammar.js +197 -0
- package/dist/grants/grants.d.ts +93 -0
- package/dist/grants/grants.js +66 -0
- package/dist/ids/ids.d.ts +5 -0
- package/dist/ids/ids.js +12 -0
- package/dist/instructions/instructions.d.ts +19 -0
- package/dist/instructions/instructions.js +35 -0
- package/dist/interfaces/interfaces.d.ts +41 -0
- package/dist/interfaces/interfaces.js +52 -0
- package/dist/invitations/invitations.d.ts +98 -0
- package/dist/invitations/invitations.js +58 -0
- package/dist/links/links.d.ts +76 -0
- package/dist/links/links.js +73 -0
- package/dist/list-input.d.ts +3 -0
- package/dist/list-input.js +11 -0
- package/dist/machines/machines.d.ts +69 -0
- package/dist/machines/machines.js +39 -0
- package/dist/messages/messages.d.ts +117 -0
- package/dist/messages/messages.js +77 -0
- package/dist/nodes/nodes.d.ts +673 -0
- package/dist/nodes/nodes.js +354 -0
- package/dist/operators/operators.d.ts +898 -0
- package/dist/operators/operators.js +398 -0
- package/dist/pages/pages.d.ts +89 -0
- package/dist/pages/pages.js +62 -0
- package/dist/primitives/primitives.d.ts +5 -0
- package/dist/primitives/primitives.js +19 -0
- package/dist/profile/profile.d.ts +37 -0
- package/dist/profile/profile.js +43 -0
- package/dist/roles/roles.d.ts +135 -0
- package/dist/roles/roles.js +87 -0
- package/dist/runs/runs.d.ts +244 -0
- package/dist/runs/runs.js +137 -0
- package/dist/runtime-config.d.ts +12 -0
- package/dist/runtime-config.js +18 -0
- package/dist/sdk.d.ts +45 -0
- package/dist/sdk.js +48 -0
- package/dist/secrets/secrets.d.ts +65 -0
- package/dist/secrets/secrets.js +57 -0
- package/dist/service-client/service-client.d.ts +35 -0
- package/dist/service-client/service-client.js +90 -0
- package/dist/services/services.d.ts +122 -0
- package/dist/services/services.js +89 -0
- package/dist/sso/sso.d.ts +70 -0
- package/dist/sso/sso.js +54 -0
- package/dist/tables/tables.d.ts +133 -0
- package/dist/tables/tables.js +131 -0
- package/dist/tool.d.ts +31 -0
- package/dist/tool.js +4 -0
- package/dist/user-settings/user-settings.d.ts +44 -0
- package/dist/user-settings/user-settings.js +44 -0
- package/dist/users/users.d.ts +254 -0
- package/dist/users/users.js +125 -0
- package/dist/validation/validation.d.ts +106 -0
- package/dist/validation/validation.js +41 -0
- package/dist/versions/versions.d.ts +100 -0
- package/dist/versions/versions.js +70 -0
- package/package.json +27 -4
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @anchrd/colab-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The contract of Colab: TypeScript types and Zod schemas for everything that crosses between Colab's
|
|
4
|
+
UI, its backends and outside services, and the client an outside service uses to ask a Colab
|
|
5
|
+
installation who a person is and what they may do.
|
|
6
|
+
|
|
7
|
+
It carries no server framework and reads no environment; its only dependencies are `zod` and
|
|
8
|
+
`ulid`. It is released together with `@anchrd/colab` under the same version number: use the
|
|
9
|
+
`@anchrd/colab-sdk` whose version equals the `@anchrd/colab` your installation runs.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @anchrd/colab-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
ES modules only, with type declarations.
|
|
18
|
+
|
|
19
|
+
## What it exports
|
|
20
|
+
|
|
21
|
+
- **Schemas and their types**, one name each, for the input and answer of every tool of Colab's API
|
|
22
|
+
and MCP. A schema is named after its tool: `access_invitation_create` takes
|
|
23
|
+
`InvitationCreateInput`, `access_user_list` takes `UserListInput`. The schema validates at runtime
|
|
24
|
+
(`UserListInput.parse(body)`), the type of the same name describes the parsed value.
|
|
25
|
+
- **Ids**: `idSchema(resource)` accepts only an id of that resource (`user_01J…`, `node_01J…`), and
|
|
26
|
+
`createId(resource)` makes one.
|
|
27
|
+
- **The error shape** `ErrorResponse`: `{ error: { code, message } }`, with `code` one of
|
|
28
|
+
`not_found`, `invalid`, `conflict`, `unauthenticated` and `unavailable` (`errorCodes`).
|
|
29
|
+
- **The naming grammar**: every capability has one three-part name, `package · resource · action`,
|
|
30
|
+
and `toolRoute`, `toolPermission` and `toolEvent` derive its route, right and protocol event.
|
|
31
|
+
- **`createServiceClient`**, the client of an outside service.
|
|
32
|
+
|
|
33
|
+
## The service client
|
|
34
|
+
|
|
35
|
+
A service registered under **Settings › Services** holds a service key. With it, the service checks
|
|
36
|
+
a person's Colab token once per request and decides locally what the person may call:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { createServiceClient } from "@anchrd/colab-sdk";
|
|
40
|
+
|
|
41
|
+
const colab = createServiceClient({
|
|
42
|
+
url: "https://<customer>.anchrd.sh",
|
|
43
|
+
serviceKey: process.env.COLAB_SERVICE_KEY,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Declare the service's interfaces once; they become rights under Settings › Roles.
|
|
47
|
+
await colab.interfaces.set("reports", ["read", "export"]);
|
|
48
|
+
|
|
49
|
+
// Once per request, with the person's token.
|
|
50
|
+
const answer = await colab.authorize(token);
|
|
51
|
+
if (answer.ok && answer.can("reports", "export")) {
|
|
52
|
+
// answer.identity names the person or machine
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`can()` decides on the rules that came back, without another call. Every failure is a result with
|
|
57
|
+
`ok: false`, `status` and `error`, never a thrown error, and every answer is validated against the
|
|
58
|
+
schemas above. The client uses the standard `fetch`, so it runs in Workers, Node, Bun and the
|
|
59
|
+
browser; `fetch` and `timeoutMs` can be passed in.
|
|
60
|
+
|
|
61
|
+
The service key is a secret: it travels only in the `authorization` header. Keep it out of logs and
|
|
62
|
+
answers.
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
UNLICENSED.
|