Skip to main content
The integration() function defines a complete code-native integration, including its flows, config pages, component registry, and metadata. It returns a converted integration object in the shape the Prismatic API expects.

Function signature

export const integration = <
  TInputs extends Inputs,
  TActionInputs extends Inputs,
  TPayload extends TriggerPayload = TriggerPayload,
  TAllowsBranching extends boolean = boolean,
  TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>,
  T extends IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>
    = IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>,
>(
  definition: T,
): ReturnType<typeof convertIntegration<...>>
When the environment variable DEBUG is set to "true", the function prints the generated YAML representation of the integration to the console via console.info.

Parameters

definition
IntegrationDefinition
required
An object that describes the integration. See the fields below.

Return type

integration
object
A converted integration object in the shape the Prismatic API expects, including a codeNativeIntegrationYAML property.

Example

import {
  integration,
  flow,
  configPage,
  configVar,
  connectionConfigVar,
} from "@prismatic-io/spectral";

export default integration({
  name: "My Integration",
  description: "Syncs data between two services.",
  iconPath: "icon.png",
  category: "Data Sync",
  version: "1.0.0",
  labels: ["sync", "data"],
  endpointType: "flow_specific",
  flows: [
    flow({
      name: "Sync Data",
      stableKey: "sync-data",
      onExecution: async (context, params) => {
        const { logger } = context;
        logger.info("Running sync...");
        return { data: null };
      },
    }),
  ],
  configPages: {
    "Connection Setup": configPage({
      tagline: "Connect your accounts",
      elements: {
        "My Connection": connectionConfigVar({
          stableKey: "my-connection",
          dataType: "connection",
          inputs: {},
        }),
      },
    }),
  },
});

Build docs developers (and LLMs) love