INTEGRATIONS / OUTLINE HTTP
A small, explicit contract.
Keep the UI and repository interface. Replace browser persistence with your own JSON service.
The adapter.
const repository = createOutlineHttpRepository({
baseUrl: "/api/outline",
credentials: "same-origin",
headers: async () => getSessionHeaders()
});
<OperationsTemplate repository={repository} />Import from @bld8/blocks/outline-http, or the installed registry source. Optional fetch injection supports your application's transport. Every request receives an AbortSignal and uses no-store.
Endpoints
| Method / path | Request | Response |
|---|---|---|
GET /projects | q, page, pageSize, status, sort, direction | {rows, total} |
POST /projects | {values} | Project · 201 |
PATCH /projects/:id | {values, version} | Project · 200 |
POST /projects/status | {ids, status} | 204 |
DELETE /projects/:id | {version} | 204 |
Project values are name, due (YYYY-MM-DD), notes and status. Responses also include a stable id and positive version. Pages return a non-negative total. Filters and sort are validated by the server.
// 422: validation
{ "fieldErrors": { "name": "A project with this name already exists." } }
// 409: stale version
{ "error": "This project changed. Reload the list before saving your draft." }422 becomes OutlineValidationError. Other failures become OutlineHttpError with status. Successful payloads are checked before the UI uses them. Inline edits preserve a rejected draft; record versions prevent overwriting newer saves.
A runnable reference.
The HTTP example and downloadable starter use process-local session data. The session header isolates sample workspaces and serves the demo; it does not authenticate a person. Data expires after inactivity or a server restart. Build your real service around authenticated ownership and atomic database writes.
Download the HTTP starterSource: examples/outline-http/demo-api.ts and packages/blocks/src/outline-http.ts. The sample includes validation, filtering, paging, bulk changes, version conflicts and a deliberate failed-save response.
Options
baseUrl— required API prefix, relative or absolute.fetch— optional transport; defaults to global fetch.headers— HeadersInit or an async function, called for each request.credentials— defaults to same-origin.