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:147

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: ActionPerformReturn‹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#

componentT›(definition: Omit‹Component‹T›, "actions" | "triggers"› & object): Component‹T›

Defined in index.ts:107

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.

Type parameters:

T: boolean

Parameters:

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

Returns: Component‹T›

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


Const convertAction#

convertAction(actionKey: string, action: ActionDefinitionInputs, boolean, undefined | ActionPerformBranchingDataReturn‹unknown› | ActionPerformDataReturn‹unknown››): Action

Defined in index.ts:39

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, undefined | ActionPerformBranchingDataReturn‹unknown› | ActionPerformDataReturn‹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 convertTrigger#

convertTrigger(triggerKey: string, trigger: TriggerDefinitionInputs, boolean, undefined | TriggerBaseResult | TriggerBranchingResult›): Trigger

Defined in index.ts:75

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

Parameters:

NameTypeDescription
triggerKeystringThe unique identifier of a trigger.
triggerTriggerDefinitionInputs, boolean, undefined | TriggerBaseResult | TriggerBranchingResultThe trigger definition, including its inputs, perform function, and app display information.

Returns: Trigger

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


Const input#

inputT›(definition: T): T

Defined in index.ts:179

For information and examples on how to write inputs for custom component actions and triggers, 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 or trigger, 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.


Const trigger#

triggerT, AllowsBranching, Result›(definition: TriggerDefinition‹T, AllowsBranching, Result›): TriggerDefinition‹T, AllowsBranching, Result›

Defined in index.ts:164

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

Type parameters:

T: Inputs

AllowsBranching: boolean

Result: TriggerResult‹AllowsBranching›

Parameters:

NameTypeDescription
definitionTriggerDefinition‹T, AllowsBranching, Result›A TriggerDefinition type object that includes UI display information, a function to perform when the trigger is invoked, and a an object containing inputs for the perform function.

Returns: TriggerDefinition‹T, AllowsBranching, Result›

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