@anchrd/colab-sdk 0.0.0-stage → 0.1.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.
Files changed (94) hide show
  1. package/README.md +65 -2
  2. package/dist/actions/actions.d.ts +810 -0
  3. package/dist/actions/actions.js +177 -0
  4. package/dist/admin-mode.d.ts +2 -0
  5. package/dist/admin-mode.js +5 -0
  6. package/dist/apps/apps.d.ts +108 -0
  7. package/dist/apps/apps.js +73 -0
  8. package/dist/archive/archive.d.ts +25 -0
  9. package/dist/archive/archive.js +27 -0
  10. package/dist/auth/auth.d.ts +27 -0
  11. package/dist/auth/auth.js +22 -0
  12. package/dist/authorization/authorization.d.ts +36 -0
  13. package/dist/authorization/authorization.js +23 -0
  14. package/dist/boards/boards.d.ts +612 -0
  15. package/dist/boards/boards.js +289 -0
  16. package/dist/columns/columns.d.ts +28 -0
  17. package/dist/columns/columns.js +28 -0
  18. package/dist/connections/connections.d.ts +149 -0
  19. package/dist/connections/connections.js +74 -0
  20. package/dist/connectors/connectors.d.ts +148 -0
  21. package/dist/connectors/connectors.js +83 -0
  22. package/dist/dashboards/dashboards.d.ts +221 -0
  23. package/dist/dashboards/dashboards.js +520 -0
  24. package/dist/directory/directory.d.ts +20 -0
  25. package/dist/directory/directory.js +18 -0
  26. package/dist/documents/documents.d.ts +61 -0
  27. package/dist/documents/documents.js +58 -0
  28. package/dist/error/error.d.ts +34 -0
  29. package/dist/error/error.js +30 -0
  30. package/dist/events/events.d.ts +104 -0
  31. package/dist/events/events.js +69 -0
  32. package/dist/files/files.d.ts +60 -0
  33. package/dist/files/files.js +139 -0
  34. package/dist/functions/functions.d.ts +26 -0
  35. package/dist/functions/functions.js +28 -0
  36. package/dist/grammar/grammar.d.ts +62 -0
  37. package/dist/grammar/grammar.js +197 -0
  38. package/dist/grants/grants.d.ts +93 -0
  39. package/dist/grants/grants.js +66 -0
  40. package/dist/ids/ids.d.ts +5 -0
  41. package/dist/ids/ids.js +12 -0
  42. package/dist/instructions/instructions.d.ts +19 -0
  43. package/dist/instructions/instructions.js +35 -0
  44. package/dist/interfaces/interfaces.d.ts +41 -0
  45. package/dist/interfaces/interfaces.js +52 -0
  46. package/dist/invitations/invitations.d.ts +98 -0
  47. package/dist/invitations/invitations.js +58 -0
  48. package/dist/links/links.d.ts +76 -0
  49. package/dist/links/links.js +73 -0
  50. package/dist/list-input.d.ts +3 -0
  51. package/dist/list-input.js +11 -0
  52. package/dist/machines/machines.d.ts +69 -0
  53. package/dist/machines/machines.js +39 -0
  54. package/dist/messages/messages.d.ts +117 -0
  55. package/dist/messages/messages.js +77 -0
  56. package/dist/nodes/nodes.d.ts +673 -0
  57. package/dist/nodes/nodes.js +354 -0
  58. package/dist/operators/operators.d.ts +898 -0
  59. package/dist/operators/operators.js +398 -0
  60. package/dist/pages/pages.d.ts +89 -0
  61. package/dist/pages/pages.js +62 -0
  62. package/dist/primitives/primitives.d.ts +5 -0
  63. package/dist/primitives/primitives.js +19 -0
  64. package/dist/profile/profile.d.ts +37 -0
  65. package/dist/profile/profile.js +43 -0
  66. package/dist/roles/roles.d.ts +135 -0
  67. package/dist/roles/roles.js +87 -0
  68. package/dist/runs/runs.d.ts +244 -0
  69. package/dist/runs/runs.js +137 -0
  70. package/dist/runtime-config.d.ts +12 -0
  71. package/dist/runtime-config.js +18 -0
  72. package/dist/sdk.d.ts +45 -0
  73. package/dist/sdk.js +48 -0
  74. package/dist/secrets/secrets.d.ts +65 -0
  75. package/dist/secrets/secrets.js +57 -0
  76. package/dist/service-client/service-client.d.ts +35 -0
  77. package/dist/service-client/service-client.js +90 -0
  78. package/dist/services/services.d.ts +122 -0
  79. package/dist/services/services.js +89 -0
  80. package/dist/sso/sso.d.ts +70 -0
  81. package/dist/sso/sso.js +54 -0
  82. package/dist/tables/tables.d.ts +133 -0
  83. package/dist/tables/tables.js +131 -0
  84. package/dist/tool.d.ts +31 -0
  85. package/dist/tool.js +4 -0
  86. package/dist/user-settings/user-settings.d.ts +44 -0
  87. package/dist/user-settings/user-settings.js +44 -0
  88. package/dist/users/users.d.ts +254 -0
  89. package/dist/users/users.js +125 -0
  90. package/dist/validation/validation.d.ts +106 -0
  91. package/dist/validation/validation.js +41 -0
  92. package/dist/versions/versions.d.ts +100 -0
  93. package/dist/versions/versions.js +70 -0
  94. package/package.json +27 -4
package/README.md CHANGED
@@ -1,3 +1,66 @@
1
- # Temporary Holding Version
1
+ # @anchrd/colab-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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.