UNPKG

@prismatic-io/spectral

Version:

Utility library for building Prismatic connectors and code-native integrations

240 lines (239 loc) 13.7 kB
"use strict"; /** * This module contains functions to help custom component and code-native * integration authors create inputs, actions, components, and integrations * that can run on the Prismatic platform. */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.pollingTrigger = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.customerActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0; const convertComponent_1 = require("./serverTypes/convertComponent"); const convertIntegration_1 = require("./serverTypes/convertIntegration"); /** * This function creates a code-native integration object that can be * imported into Prismatic. For information on using this function to * write code-native integrations, see * https://prismatic.io/docs/integrations/code-native/. * * @param definition An IntegrationDefinition type object. * @returns This function returns an integration object that has the shape the Prismatic API expects. */ const integration = (definition) => { var _a; const integrationDefinition = (0, convertIntegration_1.convertIntegration)(definition); if (((_a = process.env) === null || _a === void 0 ? void 0 : _a.DEBUG) === "true") { console.info(integrationDefinition.codeNativeIntegrationYAML); } return integrationDefinition; }; exports.integration = integration; /** * This function creates a flow object for use in code-native integrations. * For information on writing code-native flows, see * https://prismatic.io/docs/integrations/code-native/flows/. * * @param definition A Flow type object. * @returns This function returns a flow object that has the shape the Prismatic API expects. */ const flow = (definition) => definition; exports.flow = flow; /** * This function creates a config wizard page object for use in code-native * integrations. For information on code-native config wizards, see * https://prismatic.io/docs/integrations/code-native/config-wizard/. * * @param definition A Config Page type object. * @returns This function returns a config page object that has the shape the Prismatic API expects. */ const configPage = (definition) => definition; exports.configPage = configPage; /** * This function creates a config variable object for code-native integrations. * For information on writing code-native integrations, see * https://prismatic.io/docs/integrations/code-native/config-wizard/#other-config-variable-types-in-code-native-integrations. * * @param definition A Config Var type object. * @returns This function returns a standard config var object that has the shape the Prismatic API expects. */ const configVar = (definition) => definition; exports.configVar = configVar; /** * This function creates a data source-backed config variable for code-native * integrations. For information on code-native data sources, see * https://prismatic.io/docs/integrations/code-native/config-wizard/#data-sources-is-code-native-integrations. * * @param definition A Data Source Config Var type object. * @returns This function returns a data source config var object that has the shape the Prismatic API expects. */ const dataSourceConfigVar = (definition) => definition; exports.dataSourceConfigVar = dataSourceConfigVar; /** * This function creates a connection config variable for code-native * integrations. For information on writing code-native integrations, see * https://prismatic.io/docs/integrations/code-native/config-wizard/#connections-in-code-native-integrations. * * @param definition A Connection Config Var type object. * @returns This function returns a connection config var object that has the shape the Prismatic API expects. */ const connectionConfigVar = (definition) => definition; exports.connectionConfigVar = connectionConfigVar; /** * This function creates a customer-activated connection for code-native * integrations. For information on writing code-native integrations, see * https://prismatic.io/docs/integrations/code-native/. * For information on customer-activated connections, see * https://prismatic.io/docs/integrations/connections/integration-agnostic-connections/customer-activated/. * * @param definition A Customer-Activated Connection Config Var type object. * @returns This function returns a connection config var object that has the shape the Prismatic API expects. */ const customerActivatedConnection = (definition) => { return Object.assign(Object.assign({}, definition), { dataType: "connection" }); }; exports.customerActivatedConnection = customerActivatedConnection; /** * This function creates an org-activated connection for code-native * integrations. For information on writing code-native integrations, see * https://prismatic.io/docs/integrations/code-native/. * For information on customer-activated connections, see * https://prismatic.io/docs/integrations/connections/integration-agnostic-connections/org-activated-customer/. * * @param definition An Organization-Activated Connection Config Var type object. * @returns This function returns a connection config var object that has the shape the Prismatic API expects. */ const organizationActivatedConnection = (definition) => { return Object.assign(Object.assign({}, definition), { dataType: "connection" }); }; exports.organizationActivatedConnection = organizationActivatedConnection; /** * Generate a manifest of components that this code-native integration relies on. See * https://prismatic.io/docs/integrations/code-native/existing-components/ * * @param definition A Component Manifest type object. * @returns This function returns a component manifest object that has the shape the Prismatic API expects. */ const componentManifest = (definition) => definition; exports.componentManifest = componentManifest; /** * 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-connectors/. * * @param definition A ComponentDefinition type object, including display information, unique key, and a set of actions the component implements. * @returns This function returns a component object that has the shape the Prismatic API expects. */ const component = (definition) => (0, convertComponent_1.convertComponent)(definition); exports.component = component; /** * 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-connectors/actions/. * * @param definition 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 This function validates the shape of the `definition` object provided, and returns the same action object. */ const action = (definition) => definition; exports.action = action; /** * 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-connectors/triggers/. * * @param definition 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 This function validates the shape of the `definition` object provided, and returns the same trigger object. */ const trigger = (definition) => definition; exports.trigger = trigger; /** * This function creates a polling trigger object that can be referenced * by a custom component. See * https://prismatic.io/docs/custom-connectors/triggers/#app-event-polling-triggers * * @param definition A PollingTriggerDefinition is similar to a TriggerDefinition, except it requires a pollAction instead of a perform. The pollAction, which can be any action defined in the component, will be polled on the defined schedule. * @returns This function validates the shape of the `definition` object provided, and returns the same polling trigger object. */ const pollingTrigger = (definition) => { return Object.assign(Object.assign({}, definition), { triggerType: "polling" }); }; exports.pollingTrigger = pollingTrigger; /** * This function creates a data source object that can be referenced * by a custom component. It helps ensure that the shape of the * data source object conforms to what the Prismatic API expects. * For information on writing custom component data sources, see * https://prismatic.io/docs/custom-connectors/data-sources/. * * @param definition A DataSourceDefinition type object that includes UI display information, a function to perform when the data source is invoked, and a an object containing inputs for the perform function. * @returns This function validates the shape of the `definition` object provided, and returns the same data source object. */ const dataSource = (definition) => definition; exports.dataSource = dataSource; /** * For information and examples on how to write inputs * for custom component actions and triggers, see * https://prismatic.io/docs/custom-connectors/actions/#action-inputs. * * @param definition An 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 This function validates the shape of the `definition` object provided, and returns the same input object. */ const input = (definition) => definition; exports.input = input; /** * This function creates a connection that can be used by a code-native integration * or custom component. For information on writing connections, see * https://prismatic.io/docs/custom-connectors/connections/. * * @param definition A DefaultConnectionDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp. * @returns This functions validates the shape of the `definition` object provided and returns the same connection object. */ const connection = (definition) => definition; exports.connection = connection; /** * This function creates an on-prem connection for a code-native integration or custom component. * For information on writing custom component connections using on-prem resources, see * https://prismatic.io/docs/integrations/connections/on-prem-agent/#supporting-on-prem-connections-in-a-custom-connector. * * @param definition An OnPremConnectionDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp. * @returns This function validates the shape of the `definition` object provided and returns the same connection object. */ const onPremConnection = (definition) => definition; exports.onPremConnection = onPremConnection; /** * This function creates an OAuth 2.0 connection for a code-native integration or custom component. * For information on writing an OAuth 2.0 connection, see * https://prismatic.io/docs/custom-connectors/connections/#writing-oauth-20-connections. * * @param definition An OAuth2ConnectionDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp. * @returns This functions validates the shape of the `definition` object provided and returns the same connection object. */ const oauth2Connection = (definition) => definition; exports.oauth2Connection = oauth2Connection; const componentManifests = (definition) => definition; exports.componentManifests = componentManifests; var util_1 = require("./util"); Object.defineProperty(exports, "util", { enumerable: true, get: function () { return __importDefault(util_1).default; } }); __exportStar(require("./types"), exports); var testing_1 = require("./testing"); Object.defineProperty(exports, "testing", { enumerable: true, get: function () { return __importDefault(testing_1).default; } }); __exportStar(require("./errors"), exports);