Skip to main content

index

@prismatic-io/spectral"index"

This module contains functions to help custom component authors create inputs, actions, and components that can be processed by the Prismatic API.

Index#

Functions#

Functions#

Const action#

actionT, AllowsBranching, ReturnData›(definition: ActionDefinition‹T, AllowsBranching, ReturnData›): ActionDefinition‹T, AllowsBranching, ReturnData›

Defined in index.ts:96

This function creates an action object that can be referenced by a custom component. It helps ensure that the shape of the action object conforms to what the Prismatic API expects. For information on writing custom component actions, see https://prismatic.io/docs/custom-components/writing-custom-components/#writing-actions.

Type parameters:

T: Inputs

AllowsBranching: boolean

ReturnData: PerformReturn‹AllowsBranching, unknown›

Parameters:

NameTypeDescription
definitionActionDefinition‹T, AllowsBranching, ReturnData›An ActionDefinition type object that includes UI display information, a function to perform when the action is invoked, and a an object containing inputs for the perform function.

Returns: ActionDefinition‹T, AllowsBranching, ReturnData›

This function validates the shape of the definition object provided, and returns the same action object.


Const component#

component(definition: Omit‹Component, "actions"› & object): Component

Defined in index.ts:68

This function creates a component object that can be imported into the Prismatic API. For information on using this function to write custom components, see https://prismatic.io/docs/custom-components/writing-custom-components/#exporting-a-component.

Parameters:

NameTypeDescription
definitionOmit‹Component, "actions"› & objectA ComponentDefinition type object, including display infromation, unique key, authorization information, and a set of actions the component implements.

Returns: Component

This function returns a component object that has the shape the Prismatic API expects.


Const convertAction#

convertAction(actionKey: string, action: ActionDefinitionInputs, boolean, void | PerformBranchingDataReturn‹unknown› | PerformDataReturn‹unknown››): Action

Defined in index.ts:34

This is a helper function for component() to convert an action defined in TypeScript into an action object that Prismatic's API can process.

Parameters:

NameTypeDescription
actionKeystringThe unique identifier of an action.
actionActionDefinitionInputs, boolean, void | PerformBranchingDataReturn‹unknown› | PerformDataReturn‹unknown››The action definition, including its inputs, perform function, and app display information.

Returns: Action

This function returns an action object that has the shape the Prismatic API expects.


Const input#

inputT›(definition: T): T

Defined in index.ts:111

For information and examples on how to write inputs for custom component actions, see https://prismatic.io/docs/custom-components/writing-custom-components/#adding-inputs.

Type parameters:

T: InputFieldDefinition

Parameters:

NameTypeDescription
definitionTAn InputFieldDefinition object that describes the type of an input for a custom component action, and information on how it should be displayed in the Prismatic WebApp.

Returns: T

This function validates the shape of the definition object provided, and returns the same input object.