User data
Types and utilities for interacting with the user data stored on the user’s device.
Example¶
Type Aliases¶
Dashboard¶
Alpha
Represents a dashboard.
Type declaration¶
layout¶
The layout of the dashboard.
title¶
The title of the dashboard.
See¶
WidgetInstance¶
Represents a widget instance.
Type declaration¶
configuration¶
The configuration of the widget.
type¶
The type ID of the widget.
This is used to determine which widget type to use to render the widget.
See¶
Widget.id
See¶
Variables¶
dashboardSchema¶
Represents the schema for a dashboard.
idSchema¶
A regular expression that matches valid identifiers.
Used for dashboard and widget instance IDs.
See¶
jsonSchema¶
layoutSchema¶
A schema that matches valid layout configurations.
semverRegExp¶
A regular expression that matches semantic version numbers.
Taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
userDataSchema¶
The schema for the user data.
See¶
widgetInstanceSchema¶
Represents the schema for a widget instance.
See¶
Functions¶
getBlankUserData()¶
Returns a new blank user data object.
Parameters¶
version¶
string
the current application version
Returns¶
getEmptyDashboard()¶
Returns a new and empty dashboard with a unique id.
Returns¶
readonly [string
, Dashboard
]
getUserData()¶
function getUserData(): undefined | {
dashboards: Record<string, {
layout: string[][];
title: string;
}>;
version: string;
widgetInstances: Record<string, {
configuration: Record<string, Json>;
type: string;
}>;
}
Retrieves user data from local storage.
Returns¶
undefined
| {
dashboards
: Record
<string
, {
layout
: string
[][];
title
: string
;
}>;
version
: string
;
widgetInstances
: Record
<string
, {
configuration
: Record
<string
, Json
>;
type
: string
;
}>;
}
The user data if found in local storage, otherwise undefined.
removeUserData()¶
Removes the user data from local storage.
Returns¶
void
setUserData()¶
Sets the user data in the local storage based on the given input.
Parameters¶
newUserData¶
The new user data to be set.
dashboards¶
Record
<string
, {
layout
: string
[][];
title
: string
;
}> = ...
The user’s dashboards.
version¶
string
= ...
The version of the client that created this user data.
widgetInstances¶
Record
<string
, {
configuration
: Record
<string
, Json
>;
type
: string
;
}> = ...
The user’s widget instances.
Returns¶
void
References¶
UserData¶
Re-exports UserData