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.
| 7 | - `ColineApiClient` |
| 8 | High-level wrapper for common Coline platform operations. |
| 9 | - Fluent scoped handles |
| 10 | Use `client.app(appKey)` for publisher flows and `client.workspace(id).app(appKey)` for workspace runtime flows. |
| 11 | - `createAppPlatformClient` |
| 12 | Raw generated OpenAPI client for the current app-platform surface. |
| 13 | - `ColineApp` |
| 14 | Manifest/file type/app-definition builder for app authors. |
| 15 | - Generated OpenAPI artifacts |
| 16 | - `openapi/app-platform-v1.json` |
| 17 | - `src/generated/app-platform-v1.ts` |
| 18 |
| 19 | ## Regenerate the OpenAPI client/types |
| 20 |
| 21 | From the repo root: |
| 22 |
| 23 | ```bash |
| 24 | pnpm sdk:generate:openapi |
| 25 | ``` |
| 26 |
| 27 | Or from the package: |
| 28 |
| 29 | ```bash |
| 30 | pnpm --filter @colineapp/sdk generate:openapi |
| 31 | ``` |
| 32 |
| 33 | ## Quickstart |
| 34 |
| 35 | ```ts |
| 36 | import { ColineApiClient } from "@colineapp/sdk"; |
| 37 |
| 38 | const coline = new ColineApiClient({ |
| 39 | baseUrl: "https://coline.app", |
| 40 | apiKey: process.env["COLINE_API_KEY"], |
| 41 | }); |
| 42 |
| 43 | const apps = await coline.listApps(); |
| 44 | console.log(apps.apps); |
| 45 | ``` |
| 46 |
| 47 | ## Fluent scoped handles |
| 48 |
| 49 | For repetitive app and workspace flows, use the scoped handles to avoid re-passing |
| 50 | IDs on every call. |
| 51 |
| 52 | ```ts |
| 53 | import { ColineApiClient } from "@colineapp/sdk"; |
| 54 |
| 55 | const client = new ColineApiClient({ |
| 56 | baseUrl: "https://coline.app", |
| 57 | apiKey: process.env["COLINE_API_KEY"], |
| 58 | }); |
| 59 |
| 60 | const app = client.app("com.example.notes"); |
| 61 | const versions = await app.listVersions(); |
| 62 |
| 63 | const ws = client.workspace("acme"); |
| 64 | await ws.installApp({ appId: "app_123" }); |
| 65 |
| 66 | const crm = ws.app("acme-crm"); |
| 67 | const created = await crm.createFile({ |
| 68 | name: "Acme Corp", |
| 69 | typeKey: "acme.customer", |
| 70 | document: { status: "lead" }, |
| 71 | }); |
| 72 |
| 73 | await crm.file(created.file.id).updateDocument({ status: "active" }); |
| 74 | ``` |
| 75 |
| 76 | ## Raw generated client |
| 77 |
| 78 | Use the generated client if you want spec-driven methods directly: |
| 79 |
| 80 | ```ts |
| 81 | import { createAppPlatformClient } from "@colineapp/sdk"; |
| 82 |
| 83 | const client = createAppPlatformClient({ |
| 84 | baseUrl: "https://coline.app", |
| 85 | apiKey: process.env["COLINE_API_KEY"], |
| 86 | }); |
| 87 |
| 88 | const { data, error } = await client.GET("/api/v1/apps"); |
| 89 | if (error) throw error; |
| 90 | console.log(data.data.apps); |
| 91 | ``` |
| 92 |
| 93 | ## Typed app registration |
| 94 |
| 95 | ```ts |
| 96 | import { ColineApiClient } from "@colineapp/sdk"; |
| 97 |
| 98 | const client = new ColineApiClient({ |
| 99 | baseUrl: "https://coline.app", |
| 100 | apiKey: process.env["COLINE_API_KEY"], |
| 101 | }); |
| 102 |
| 103 | await client.registerApp({ |
| 104 | version: "0.1.0", |
| 105 | manifest: { |
| 106 | key: "com.example.notes", |
| 107 | name: "Example Notes", |
| 108 | permissions: ["app.home.read", "files.read", "files.write"], |
| 109 | notificationChannels: [], |
| 110 | hosting: { |
| 111 | mode: "external", |
| 112 | baseUrl: "https://notes.example.com", |
| 113 | }, |
| 114 | }, |
| 115 | fileTypes: [ |
| 116 | { |
| 117 | typeKey: "com.example.notes.note", |
| 118 | name: "Note", |
| 119 | storage: "coline_document", |
| 120 | indexable: true, |
| 121 | homeRenderMode: "cached", |
| 122 | }, |
| 123 | ], |
| 124 | }); |
| 125 | ``` |
| 126 |