@oobleck/fluid-backend
Version:
Fluid Framework backend for nteract RTC
68 lines (59 loc) • 1.99 kB
text/typescript
import { SharedString } from "@fluid-experimental/fluid-framework";
import { Observable } from "rxjs";
import {
CellEvent,
CellInput,
CellSourceEdit,
MetadataEntryDef,
NotebookEvent,
OutputInput,
PatchCellSourceInput
} from "../schema";
/**
* Describes the public API surface for our Fluid DataObject.
*/
export interface INotebookModel {
readonly cellEvents$: Observable<CellEvent>;
readonly cellEdits$: Observable<AugmentedCellEdit>;
readonly events$: Observable<NotebookEvent>;
readonly metadata: MetadataEntryDef[];
getCell(id: string): Promise<CellModel | undefined>;
getCells(): Promise<CellModel[]>;
deleteCell(id: string): void;
insertCell(cell: CellInput, insertAt: number): Promise<CellModel>;
moveCell(id: string, insertAt: number): void;
replaceCell(id: string, cell: CellInput): Promise<CellModel>;
updateMetadata(key: string, value: unknown): void;
}
export interface ICell {
cellType: "CodeCell" | "MarkdownCell" | "RawCell";
readonly id: string;
readonly source: string;
readonly metadata: MetadataEntryDef[];
readonly edits$: Observable<AugmentedCellEdit>;
readonly events$: Observable<CellEvent>;
applySourceEdit(input: PatchCellSourceInput): void;
updateMetadata(key: string, value: unknown): void;
}
export interface ICodeCell extends ICell {
cellType: "CodeCell";
readonly executionCount: number | undefined;
readonly outputs: ICellOutput[];
appendOutput(output: OutputInput): void;
clearOutputs(): void;
}
export interface IMarkdownCell extends ICell {
cellType: "MarkdownCell";
}
export interface IRawCell extends ICell {
cellType: "RawCell";
}
export type CellModel = ICodeCell | IMarkdownCell | IRawCell;
export interface ICellOutput {
type: "DisplayData" | "ErrorOutput" | "ExecuteResult" | "StreamOutput";
[key: string]: any;
}
export type AugmentedCellEdit = {
source: SharedString;
edit: CellSourceEdit;
}