Skip to content
philosophy contribute api

PluginDescriptor

PluginDescriptor<Name, ID, Store, SharedStoreProvider, State, Actions, Object, Messages> = object

Defined in: core/src/plugins/types.ts:97

A descriptor for a Levl plugin.

This type is meant to group everything related to a Levl plugin under one place where all the attributes can be tested against all the types.

Many of the attributes here are specific to an Object that this plugin defines (ID, State, Store, Content, Page).

Note: At the moment, it’s still very much unstructured and more like “a bag of all things plugin” than a “plugin definition”. As Levl grows, this descriptor should evolve into a more intuitive structured format.

Name extends string = any

The unique identifier of the plugin.

ID extends string = any

Type of the ID of Object.

Store extends object = any

Type of a store that keeps a set of Objects.

SharedStoreProvider extends SharedStore<Store> = any

State extends object = any

Type of Object’s state.

Actions extends PluginActions = any

Types of a set of actions that this plugin can run on the server.

Object extends SharedObject<ID, State> = any

Type of Object itself

Messages extends MessagesDescriptor = MessagesDescriptor

Types of a set of messages. Messages are like actions but are 2 way (can return data) and can be awaited.

TODO: messages should be renamed to actions and replace existing actions.

optional actions: Actions

Defined in: core/src/plugins/types.ts:157

A list of Actions.


optional Content: (props) => JSX.Element

Defined in: core/src/plugins/types.ts:141

A component that renders an Object. Shown in the side pane when the object is selected.

Accessor<ID>

JSX.Element


optional createDraft: () => ID

Defined in: core/src/plugins/types.ts:153

A function that creates and initializes a draft of Object, and return its ID.

ID


optional icon: Component

Defined in: core/src/plugins/types.ts:114

An icon for the plugin’s sidebar item.


optional messages: { [messageKey in keyof Messages]: MessageHandler<Messages[messageKey]> }

Defined in: core/src/plugins/types.ts:135

Handlers for each message type.


readonly name: Name

Defined in: core/src/plugins/types.ts:110

The name (unique identifier) of the plugin.


optional Object: (…args) => Object

Defined in: core/src/plugins/types.ts:149

The Object class.

any[]

Object


optional Page: (props) => JSX.Element

Defined in: core/src/plugins/types.ts:145

A page of Objects. Shown when the sidebar item is active.

object & RouteSectionProps<any>

JSX.Element


optional store: object

Defined in: core/src/plugins/types.ts:118

Attributes related to Object’s store.

handler: SharedStoreType<Store>

The class of Object’s store.

init: Store

The value Store should be initialized with.

loadSample(store): void

A function that’s called to initialize Store with sample data. Only used in Playground mode.

StoreProvider

void