Skip to main content
The input function validates and returns an InputFieldDefinition object. Inputs define the configuration fields presented to integration builders in the Prismatic UI. The resolved input values are passed to the perform function via the params argument.

Function signature

function input<T extends InputFieldDefinition>(definition: T): T

Common fields

All input types share the following base fields:
label
string | { key: string; value: string }
required
The field label shown in the UI. Accepts a plain string or a { key, value } object for localization.
type
InputFieldType
required
The input type. See type-specific documentation below.
required
boolean
When true, the integration builder must provide a value for this input.
placeholder
string
Placeholder text shown in the input field before a value is entered.
comments
string
Help text displayed below the input field to guide the integration builder.
example
string
An example of a valid value for this input.
default
varies by type
Default value pre-populated in the input field.
collection
'valuelist' | 'keyvaluelist'
When set, this input accepts multiple values instead of a single value.
  • "valuelist" — a list of values of the input’s base type
  • "keyvaluelist" — a list of key/value pairs where each value is the input’s base type
model
InputFieldChoice[]
A list of predefined choices rendered as a dropdown. Available for string, data, text, password, boolean, date, and timestamp types.
clean
(value: unknown) => TResult
A function that transforms the raw input value before it is passed to perform. Useful for parsing, coercing types, or stripping whitespace. The return type of clean determines the TypeScript type seen in params.
dataSource
string
Key of a data source defined in the same component that can be used to dynamically populate the allowed values for this input.

Input types

A single-line text input.
input({
  label: "API Endpoint",
  type: "string",
  required: true,
  placeholder: "https://api.example.com",
  comments: "The base URL for the API",
  example: "https://api.acme.com",
})

Collections

When collection is set, the input accepts multiple values. The default type and resolved params type change accordingly:
Collectiondefault typeResolved params type
(none)TT
"valuelist"T[]T[]
"keyvaluelist"KeyValuePair<T>[]KeyValuePair<T>[]
// A list of string values
input({
  label: "Allowed Domains",
  type: "string",
  collection: "valuelist",
  default: ["example.com", "acme.com"],
})

// A list of key/value pairs
input({
  label: "HTTP Headers",
  type: "string",
  collection: "keyvaluelist",
  default: [{ key: "Content-Type", value: "application/json" }],
})

clean function

The clean function coerces or validates the raw input value before it reaches the perform function:
import { input, util } from "@prismatic-io/spectral";

const maxRetries = input({
  label: "Max Retries",
  type: "string",
  default: "3",
  clean: (value) => util.types.toInt(value, 3),
});

// In perform, params.maxRetries is typed as number

Connection object

When a connection input is resolved, params.myConnection contains:
key
string
Programmatic key of the connection type.
configVarKey
string
Name of the config variable hosting this connection.
fields
{ [key: string]: unknown }
Input field values supplied to this connection (e.g., fields.apiKey).
token
Record<string, unknown>
OAuth 2.0 token data (e.g., access_token, refresh_token, expires_in). Present only for OAuth 2.0 connections.
context
Record<string, unknown>
OAuth 2.0 token metadata (e.g., expiration time). Present only for OAuth 2.0 connections.