INTEGRATIONS / OUTLINE HTTP

A small, explicit contract.

Keep the UI and repository interface. Replace browser persistence with your own JSON service.

The adapter.

React / TypeScript
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 / pathRequestResponse
GET /projects/:id—Project · 200, or 404
GET /projectsq, page, pageSize, status, sort, direction{rows, total}
POST /projects{values}Project · 201
PATCH /projects/:id{values, version}Project · 200
POST /projects/status{ids, status, reversible?}204, or {changed, undo} when reversible
DELETE /projects/:id{version}204
GET /projects/:id/activityhistory capability{entries} · latest 100
POST /projects/:id/comments{text, clientId}Saved comment · 201
POST /projects/status/undo{id} receipt204, or 409 when stale

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.

React / TypeScript
// 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. Project details also recover tab-local drafts and compare newer records before explicitly reapplying edited fields.

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 starter

Source: examples/outline-http/demo-api.ts and packages/blocks/src/outline-http.ts. The sample includes validation, filtering, paging, version conflicts, comments, activity and guarded bulk-status undo. Failed writes preserve drafts or undo receipts for retry. Production services must check versions and commit the entire status change or undo atomically.

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.
  • history — opt in with true only when your service implements activity, comments and reversible status receipts. The sample supports all three; existing services can keep the original contract.
  • draftKey — optional stable owner/workspace namespace for recovery in the current tab. Omit for memory-only drafts; never use credentials as this key.