The Coline App SDK: apps, tools, file types and surfaces that run inside Coline workspaces, and public websites with Coline Sites. TypeScript, with an in-memory test workspace. MIT.
| 6 | * programmatically using a workspace API key with the `apps.read` and |
| 7 | * `apps.write` scopes. |
| 8 | */ |
| 9 | import { ColineApiClient } from "../client"; |
| 10 |
| 11 | const client = new ColineApiClient({ |
| 12 | baseUrl: "https://coline.app", |
| 13 | apiKey: "col_ws_example_key", |
| 14 | }); |
| 15 |
| 16 | async function main() { |
| 17 | const ws = client.workspace("acme"); |
| 18 |
| 19 | // List installed apps |
| 20 | const { installedApps } = await ws.listApps(); |
| 21 | console.log("Installed apps:", installedApps.map((a) => a.name)); |
| 22 |
| 23 | // Get a specific installed app |
| 24 | const app = ws.app("com.example.notes"); |
| 25 | const { install } = await app.get(); |
| 26 | console.log("App:", install.name, "Status:", install.status); |
| 27 |
| 28 | // Create an app-owned file |
| 29 | const { file } = await app.createFile({ |
| 30 | name: "Meeting notes", |
| 31 | typeKey: "com.example.notes.note", |
| 32 | document: { status: "open" }, |
| 33 | }); |
| 34 | console.log("Created file:", file.id); |
| 35 |
| 36 | // Update the file's document |
| 37 | await app.file(file.id).updateDocument({ status: "done" }); |
| 38 |
| 39 | // Send a notification through the app |
| 40 | await app.createNotification({ |
| 41 | channelKey: "updates", |
| 42 | typeKey: "note.completed", |
| 43 | title: "Note completed", |
| 44 | body: `"Meeting notes" was marked as done.`, |
| 45 | recipients: [{ userId: "user_123" }], |
| 46 | }); |
| 47 | } |
| 48 |
| 49 | void main(); |
| 50 |