Skip to content

Index

The Telestion Frontend Library.

Import this library to use the Telestion Frontend:

import { initTelestion } from '@wuespace/telestion';

The most important function is initTelestion. It initializes the Telestion Frontend and renders the application.

initTelestion({
  version: '1.0.0',
  ...
});

See

initTelestion

Interfaces

TelestionOptions

Represents the options for Telestion.

Properties

defaultBackendUrl?
optional defaultBackendUrl: string;

The backend URL that should be inserted by default on first page load.

defaultUserData?
optional defaultUserData: object;

Represents the default user data.

dashboards
dashboards: Record<string, {
  layout: string[][];
  title: string;
}>;

The user’s dashboards.

version
version: string;

The version of the client that created this user data.

widgetInstances
widgetInstances: Record<string, {
  configuration: Record<string, Json>;
  type: string;
}>;

The user’s widget instances.

version
version: string;

Represents the current version of the software.

widgets?
optional widgets: Widget<Record<string, Json>>[];

Represents an array of widgets.


Widget<T>

A widget that can be used in widget instances on dashboards.

See

userData.WidgetInstance

Type Parameters

T extends BaseWidgetConfiguration = BaseWidgetConfiguration

the type of the widget configuration

Properties

configElement
configElement: ReactNode;

A configuration element that is used to configure the widget.

element
element: ReactNode;

A function that takes the configuration of the widget and returns a React element that represents the widget.

id
id: string;

Represents an identifier of the widget type.

label
label: string;

Represents a human-readable label of the widget type.

Methods

createConfig()
createConfig(input): T

A function that takes an object that contains the previous widget configuration (which may or may not be from a previous version of the client (or could also, when creating new widget instances, be empty) and returns a valid configuration for the widget.

For widgets with expected breaking changes, it is therefore useful to have some version identifier be a part of the configuration options to enable more complex migration logic in this function.

Parameters
input

Partial<T> & Record<string, Json>

previous configuration or empty

Returns

T

Type Aliases

UserData

type UserData: object;

Represents the user data.

Type declaration

dashboards
dashboards: Record<string, {
  layout: string[][];
  title: string;
}>;

The user’s dashboards.

version
version: string;

The version of the client that created this user data.

widgetInstances
widgetInstances: Record<string, {
  configuration: Record<string, Json>;
  type: string;
}>;

The user’s widget instances.

See

userDataSchema

Functions

JSONCodec()

function JSONCodec<T>(reviver?): Codec<T>

Returns a Codec for encoding JavaScript object to JSON and serialize them to an Uint8Array, and conversely, from an Uint8Array to JSON to a JavaScript Object.

Type Parameters

T = unknown

Parameters

reviver?

(this, key, value) => unknown

Returns

Codec<T>


registerWidgets()

function registerWidgets(...widgets): void

Registers widgets in the widget store.

If a widget with the same ID already exists in the widget store, a warning is logged and the widget is ignored.

Parameters

widgets

Widget<Record<string, Json>>[]

The widgets to be registered.

Returns

void


useNats()

function useNats(): NatsConnection

Returns

NatsConnection


useWidgetConfig()

function useWidgetConfig<T>(): T

Retrieves the widget configuration from the widgetConfigContext.

Type Parameters

T

The type of the widget configuration.

Returns

T

The widget configuration retrieved from the widgetConfigContext.

Throws

Error Throws an error if useWidgetConfig is not used within a WidgetConfigProvider.

References

initTelestion

Re-exports initTelestion