Skip to main content

observablejs.types

observablejs.types publishes annotations for advanced inputs and synchronized state.

import observablejs as obs

file: obs.types.FileSpec = {
"url": "https://example.test/data.csv",
"mimeType": "text/csv",
}

document: obs.types.ObservableDocument = {
"title": "Report",
"nodes": [{"id": 1, "mode": "js", "value": "answer = 42"}],
}

Input contracts

TypeContract
CellMode, CellFormatSupported Notebook Kit cell modes and file formats.
CellSelectorString key, authored Cell, or notebook-owned NotebookCell.
NotebookViewOptionsKeyword options shared by Notebook.view() and view factories.
NotebookTheme, ThemePair, ThemeTheme names and light or dark pairs.
FileSpec, FileInputFile input record, URL, or filesystem path.
NotebookKitCellMetadataMode metadata for database, format, and since.
ObservableClassicDocument, ObservableNode, ObservableFileClassic Observable document records.
ObservableNotebookModel, ObservableBody, ObservableCell, ObservableAttachmentNative Notebook Kit source.
ObservablePageDocument, ObservableDocumentPublic-page source and the accepted source union.
ObservableResolutionClassic dependency and standard-library resolution.
ObservableSource, ObservableData, ObservableDisplayNested ObservableHQ source and display records.

NotebookViewOptions currently accepts one optional key:

KeyTypeDefaultContract
capture_stateboolTrueSynchronizes browser evaluation state with Python.

Runtime parsing remains defensive when JSON data does not match an annotation.

State contracts

CellStatus is pending, success, or error. ErrorPhase is analysis, evaluation, rendering, or serialization.

The immutable records are:

  • NotebookState
  • ViewState
  • CellResult
  • CellError
  • ViewError
  • BrowserErrorValue

FileSnapshot and ThemeSnapshot describe the read-only mappings inside NotebookState.

See Notebook for controller snapshots and View state and graph for browser revisions and results.

Inspection and data contracts

NotebookInspection, CellInspection, ImportInfo, ImportBinding, and AttachmentInspection describe prepared source and static references. DatasetInfo, DatasetDescription, and ColumnInfo describe evaluated data. DataReference and AsyncDataReference provide direct conversions. DataCatalog carries discovered references and diagnostics. These records are available under obs.types. Custom exceptions and diagnostic records live under obs.errors.

See Data access for selectors, formats, and lifecycle.