Skip to content

charton API


charton API / @chart-on/core / index / StorageAdapter

Interface: StorageAdapter ​

Defined in: packages/core/src/storage/types.ts:63

Where chart state is kept: the browser, a server, anything. Every method is async and optional; implement only what your app uses. Helpers check for a method before calling it. Reads return null for missing or unreadable entries; the chart validates what it loads.

Methods ​

listLayouts()? ​

optional listLayouts(): Promise<LayoutSummary[]>

Defined in: packages/core/src/storage/types.ts:73

Saved layouts, in any order.

Returns ​

Promise<LayoutSummary[]>


listTemplates()? ​

optional listTemplates(kind, scope?): Promise<string[]>

Defined in: packages/core/src/storage/types.ts:79

Names of the saved templates of kind under scope, in the order they were first saved.

Parameters ​

kind ​

TemplateKind

scope? ​

string

Returns ​

Promise<string[]>


loadDrawings()? ​

optional loadDrawings(key): Promise<SerializedDrawings | null>

Defined in: packages/core/src/storage/types.ts:65

Drawings saved under key, e.g. a symbol id.

Parameters ​

key ​

string

Returns ​

Promise<SerializedDrawings | null>


loadLayout()? ​

optional loadLayout(id): Promise<ChartLayout | null>

Defined in: packages/core/src/storage/types.ts:74

Parameters ​

id ​

string

Returns ​

Promise<ChartLayout | null>


loadTemplate()? ​

optional loadTemplate(kind, name, scope?): Promise<unknown>

Defined in: packages/core/src/storage/types.ts:81

A template's content, or null when there is none by that name. Validate it before use.

Parameters ​

kind ​

TemplateKind

name ​

string

scope? ​

string

Returns ​

Promise<unknown>


removeDrawings()? ​

optional removeDrawings(key): Promise<void>

Defined in: packages/core/src/storage/types.ts:71

Parameters ​

key ​

string

Returns ​

Promise<void>


removeLayout()? ​

optional removeLayout(id): Promise<void>

Defined in: packages/core/src/storage/types.ts:77

Parameters ​

id ​

string

Returns ​

Promise<void>


removeTemplate()? ​

optional removeTemplate(kind, name, scope?): Promise<void>

Defined in: packages/core/src/storage/types.ts:84

Parameters ​

kind ​

TemplateKind

name ​

string

scope? ​

string

Returns ​

Promise<void>


saveDrawings()? ​

optional saveDrawings(key, drawings, delta?): Promise<void>

Defined in: packages/core/src/storage/types.ts:70

Save all drawings under key. delta lists what changed since the last save under that key, when known, so a server can update only those.

Parameters ​

key ​

string

drawings ​

SerializedDrawings

delta? ​

DrawingsDelta

Returns ​

Promise<void>


saveLayout()? ​

optional saveLayout(entry): Promise<string>

Defined in: packages/core/src/storage/types.ts:76

Save a layout; resolves with its id (a new one when entry.id is left out).

Parameters ​

entry ​

LayoutEntry

Returns ​

Promise<string>


saveTemplate()? ​

optional saveTemplate(kind, name, content, scope?): Promise<void>

Defined in: packages/core/src/storage/types.ts:83

Save content (JSON-serializable) under name, replacing a template of the same name.

Parameters ​

kind ​

TemplateKind

name ​

string

content ​

unknown

scope? ​

string

Returns ​

Promise<void>