@prismatic-io/spectral
Advanced tools
Comparing version 7.9.0 to 8.0.0-preview10
@@ -165,5 +165,5 @@ import { AxiosResponse } from "axios"; | ||
}; | ||
}, boolean, { | ||
}, import("../..").ConfigVarResultCollection, boolean, { | ||
data: any; | ||
}>; | ||
export { inputs }; |
@@ -6,5 +6,42 @@ /** | ||
*/ | ||
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition } from "./types"; | ||
import { convertComponent } from "./serverTypes/convert"; | ||
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVar, ConfigVarResultCollection, ConfigVarCollection, TriggerPayload } from "./types"; | ||
import { convertComponent, convertIntegration } from "./serverTypes/convert"; | ||
/** | ||
* This function creates a Integration object that can be | ||
* imported into the Prismatic API. For information on using | ||
* this function to write code native integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/. | ||
* @param definition An IntegrationDefinition type object. | ||
* @returns This function returns an integration object that has the shape the Prismatic API expects. | ||
*/ | ||
export declare const integration: <TConfigVar extends Record<string, ConfigVar> = Record<string, ConfigVar>>(definition: IntegrationDefinition<TConfigVar>) => ReturnType<typeof convertIntegration>; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-flows. | ||
* @param definition A Flow type object. | ||
* @returns This function returns a flow object that has the shape the Prismatic API expects. | ||
*/ | ||
export declare const flow: <TConfigVars extends ConfigVarCollection = ConfigVarCollection, TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TConfigVars, TTriggerPayload> = Flow<TConfigVars, TTriggerPayload>>(definition: T) => T; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-config-pages. | ||
* @param definition A Config Page type object. | ||
* @returns This function returns a config page object that has the shape the Prismatic API expects. | ||
*/ | ||
export declare const configPage: <T extends ConfigPage<ConfigVarCollection>>(definition: T) => T; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars. | ||
* @param definition A Config Var type object. | ||
* @returns This function returns a standard config var object that has the shape the Prismatic API expects. | ||
*/ | ||
export declare const configVar: <T extends StandardConfigVar>(definition: T) => T; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars. | ||
* @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. | ||
*/ | ||
export declare const connectionConfigVar: <T extends ConnectionConfigVar>(definition: T) => T; | ||
/** | ||
* This function creates a component object that can be | ||
@@ -27,3 +64,3 @@ * imported into the Prismatic API. For information on using | ||
*/ | ||
export declare const action: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>>(definition: ActionDefinition<TInputs, TAllowsBranching, TReturn>) => ActionDefinition<TInputs, TAllowsBranching, TReturn>; | ||
export declare const action: <TInputs extends Inputs, TConfigVar extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>>(definition: ActionDefinition<TInputs, TConfigVar, TAllowsBranching, TReturn>) => ActionDefinition<TInputs, TConfigVar, TAllowsBranching, TReturn>; | ||
/** | ||
@@ -38,3 +75,3 @@ * This function creates a trigger object that can be referenced | ||
*/ | ||
export declare const trigger: <TInputs extends Inputs, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching>>(definition: TriggerDefinition<TInputs, TAllowsBranching, TResult>) => TriggerDefinition<TInputs, TAllowsBranching, TResult>; | ||
export declare const trigger: <TInputs extends Inputs, TConfigVar extends ConfigVarResultCollection, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>>(definition: TriggerDefinition<TInputs, TConfigVar, TAllowsBranching, TResult>) => TriggerDefinition<TInputs, TConfigVar, TAllowsBranching, TResult>; | ||
/** | ||
@@ -62,10 +99,2 @@ * This function creates a data source object that can be referenced | ||
connection: import("./types").Connection; | ||
/** | ||
* 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. | ||
* @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. | ||
*/ | ||
objectSelection: import("./types").ObjectSelection; | ||
@@ -72,0 +101,0 @@ objectFieldMap: import("./types").ObjectFieldMap; |
@@ -25,5 +25,47 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.testing = exports.util = exports.oauth2Connection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = void 0; | ||
exports.testing = exports.util = exports.oauth2Connection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.connectionConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0; | ||
const convert_1 = require("./serverTypes/convert"); | ||
/** | ||
* This function creates a Integration object that can be | ||
* imported into the Prismatic API. For information on using | ||
* this function to write code native integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/. | ||
* @param definition An IntegrationDefinition type object. | ||
* @returns This function returns an integration object that has the shape the Prismatic API expects. | ||
*/ | ||
const integration = (definition) => (0, convert_1.convertIntegration)(definition); | ||
exports.integration = integration; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-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; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-config-pages. | ||
* @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; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars. | ||
* @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; | ||
/** | ||
* For information on writing Code Native Integrations, see | ||
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars. | ||
* @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 component object that can be | ||
@@ -30,0 +72,0 @@ * imported into the Prismatic API. For information on using |
@@ -1,3 +0,4 @@ | ||
import { ComponentDefinition } from "../types"; | ||
import { ComponentDefinition, IntegrationDefinition } from "../types"; | ||
import { Component as ServerComponent } from "."; | ||
export declare const convertComponent: <TPublic extends boolean, TKey extends string>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent; | ||
export declare const convertIntegration: (definition: IntegrationDefinition) => ServerComponent; |
@@ -13,4 +13,9 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertComponent = void 0; | ||
exports.convertIntegration = exports.convertComponent = void 0; | ||
const yaml_1 = __importDefault(require("yaml")); | ||
const uuid_1 = require("uuid"); | ||
const types_1 = require("../types"); | ||
@@ -81,1 +86,242 @@ const perform_1 = require("./perform"); | ||
exports.convertComponent = convertComponent; | ||
const convertIntegration = (definition) => { | ||
// Generate a unique reference key that will be used to reference the | ||
// actions, triggers, data sources, and connections that are created | ||
// inline as part of the integration definition. | ||
const referenceKey = (0, uuid_1.v4)(); | ||
return Object.assign(Object.assign({}, codeNativeIntegrationComponent(definition, referenceKey)), { codeNativeIntegrationYAML: codeNativeIntegrationYaml(definition, referenceKey) }); | ||
}; | ||
exports.convertIntegration = convertIntegration; | ||
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, configVars, endpointType, triggerPreprocessFlowConfig, flows, configPages, }, referenceKey) => { | ||
const DEFINITION_VERSION = 7; | ||
// Find the preprocess flow config on the flow, if one exists. | ||
const preprocessFlows = flows.filter((flow) => flow.preprocessFlowConfig); | ||
// Do some validation of preprocess flow configs. | ||
if (preprocessFlows.length > 1) { | ||
throw new Error("Only one flow may define a Preprocess Flow Config."); | ||
} | ||
if (preprocessFlows.length && triggerPreprocessFlowConfig) { | ||
throw new Error("Integration must not define both a Trigger Preprocess Flow Config and a Preprocess Flow."); | ||
} | ||
const hasPreprocessFlow = preprocessFlows.length > 0; | ||
const preprocessFlowConfig = hasPreprocessFlow | ||
? preprocessFlows[0].preprocessFlowConfig | ||
: triggerPreprocessFlowConfig; | ||
if ([types_1.EndpointType.InstanceSpecific, types_1.EndpointType.SharedInstance].includes(endpointType || types_1.EndpointType.FlowSpecific) && | ||
!preprocessFlowConfig) { | ||
throw new Error("Integration with specified EndpointType must define either a Trigger Preprocess Flow Config or a Preprocess Flow."); | ||
} | ||
// Transform the IntegrationDefinition into the structure that is appropriate | ||
// for generating YAML, which will then be used by the Prismatic API to import | ||
// the integration as a Code Native Integration. | ||
const result = { | ||
definitionVersion: DEFINITION_VERSION, | ||
isCodeNative: true, | ||
name, | ||
description, | ||
category, | ||
documentation, | ||
version, | ||
labels, | ||
requiredConfigVars: Object.entries(configVars || {}).map(([key, configVar]) => convertConfigVar(Object.assign(Object.assign({}, configVar), { key }), referenceKey)), | ||
endpointType, | ||
preprocessFlowName: hasPreprocessFlow ? preprocessFlows[0].name : undefined, | ||
externalCustomerIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerIdField), | ||
externalCustomerUserIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerUserIdField), | ||
flowNameField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.flowNameField), | ||
flows: flows.map((flow) => convertFlow(flow, referenceKey)), | ||
configPages, | ||
}; | ||
return yaml_1.default.stringify(result); | ||
}; | ||
/** Converts a Flow into the structure necessary for YAML generation. */ | ||
const convertFlow = (flow, referenceKey) => { | ||
const result = Object.assign({}, flow); | ||
delete result.onTrigger; | ||
delete result.trigger; | ||
delete result.onInstanceDeploy; | ||
delete result.onInstanceDelete; | ||
delete result.onExecution; | ||
delete result.preprocessFlowConfig; | ||
delete result.errorConfig; | ||
const triggerStep = { | ||
name: "On Trigger", | ||
description: "The function that will be executed by the flow to return an HTTP response.", | ||
isTrigger: true, | ||
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined, | ||
action: { | ||
key: flowFunctionKey(flow.name, "onTrigger"), | ||
component: { key: referenceKey, version: "LATEST", isPublic: false }, | ||
}, | ||
}; | ||
if ("schedule" in flow && typeof flow.schedule === "object") { | ||
triggerStep.schedule = { | ||
type: "cronExpression" in flow.schedule | ||
? types_1.SimpleInputValueType.Value | ||
: types_1.SimpleInputValueType.ConfigVar, | ||
value: "cronExpression" in flow.schedule | ||
? flow.schedule.cronExpression | ||
: flow.schedule.configVarKey, | ||
meta: { | ||
scheduleType: types_1.ScheduleType.Custom, | ||
timeZone: flow.schedule.timeZone, | ||
}, | ||
}; | ||
delete result.schedule; | ||
} | ||
const actionStep = { | ||
action: { | ||
key: flowFunctionKey(flow.name, "onExecution"), | ||
component: { key: referenceKey, version: "LATEST", isPublic: false }, | ||
}, | ||
name: "On Execution", | ||
description: "The function that will be executed by the flow.", | ||
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined, | ||
}; | ||
result.steps = [triggerStep, actionStep]; | ||
return result; | ||
}; | ||
/** Converts a Config Var into the structure necessary for YAML generation. */ | ||
const convertConfigVar = (configVar, referenceKey) => { | ||
// This is unfortunate but we need to strip out some fields that are not | ||
// relevant to config vars. | ||
const fields = [ | ||
"key", | ||
"description", | ||
"orgOnly", | ||
"inputs", | ||
"defaultValue", | ||
"dataType", | ||
"pickList", | ||
"scheduleType", | ||
"timeZone", | ||
"codeLanguage", | ||
"collectionType", | ||
"dataSource", | ||
]; | ||
const result = Object.entries(configVar).reduce((result, [key, value]) => { | ||
if (!fields.includes(key)) { | ||
return result; | ||
} | ||
return Object.assign(Object.assign({}, result), { [key]: value }); | ||
}, { meta: {} }); | ||
// Handle some non-standard fields. | ||
if ("visibleToOrgDeployer" in configVar) { | ||
result.meta.visibleToOrgDeployer = configVar.visibleToOrgDeployer; | ||
} | ||
if ("visibleToCustomerDeployer" in configVar) { | ||
result.meta.visibleToCustomerDeployer = configVar.visibleToCustomerDeployer; | ||
} | ||
// Handle connections. | ||
if ("label" in configVar) { | ||
result.dataType = "connection"; | ||
// This refers to a connection we are creating. | ||
result.connection = { | ||
key: configVar.key, | ||
component: { key: referenceKey, version: "LATEST", isPublic: false }, | ||
}; | ||
result.description = configVar.label; | ||
// Convert connection inputs to the inputs expected in the YAML. | ||
// FIXME: This is just a placeholder for now. | ||
// TODO: It seems like using the default value as the value is probably correct? | ||
result.inputs = Object.entries(configVar.inputs).reduce((result, [key, input]) => { | ||
var _a; | ||
return Object.assign(Object.assign({}, result), { [key]: { | ||
type: types_1.SimpleInputValueType.Value, | ||
value: (_a = input.default) !== null && _a !== void 0 ? _a : "", | ||
} }); | ||
}, {}); | ||
} | ||
// Handle data source references. | ||
if ("dataSource" in result) { | ||
// This is a reference to a data source we are creating. | ||
result.dataSource = { | ||
key: result.dataSource, | ||
component: { key: referenceKey, version: "LATEST", isPublic: false }, | ||
}; | ||
} | ||
return result; | ||
}; | ||
/** Maps the step name field to a fully qualified input. */ | ||
const fieldNameToReferenceInput = (stepName, fieldName) => { | ||
if (!fieldName) { | ||
return undefined; | ||
} | ||
return { | ||
type: types_1.SimpleInputValueType.Reference, | ||
value: `${stepName}.results.${fieldName}`, | ||
}; | ||
}; | ||
/** Actions and Triggers will be scoped to their flow by combining the flow | ||
* name and the function name. This is to ensure that the keys are unique | ||
* on the resulting object, which will be turned into a Component. */ | ||
const flowFunctionKey = (flowName, functionName) => { | ||
const flowKey = flowName | ||
.replace(/[^0-9a-zA-Z]+/g, " ") | ||
.trim() | ||
.split(" ") | ||
.map((w, i) => i === 0 | ||
? w.toLowerCase() | ||
: w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()) | ||
.join(""); | ||
return `${flowKey}_${functionName}`; | ||
}; | ||
/** Creates the structure necessary to import a Component as part of a | ||
* Code Native integration. */ | ||
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], dataSources = {}, configVars = {}, }, referenceKey) => { | ||
const convertedActions = flows.reduce((result, { name, onExecution }) => { | ||
const actionKey = flowFunctionKey(name, "onExecution"); | ||
return Object.assign(Object.assign({}, result), { [actionKey]: convertAction(actionKey, { | ||
display: { | ||
label: `${name} - onExecution`, | ||
description: "The function that will be executed by the flow.", | ||
}, | ||
perform: onExecution, | ||
inputs: {}, | ||
}) }); | ||
}, {}); | ||
const convertedTriggers = flows.reduce((result, flow) => { | ||
// Filter out TriggerReferences. | ||
if ("trigger" in flow) | ||
return result; | ||
const { name, onTrigger, onInstanceDeploy, onInstanceDelete } = flow; | ||
const triggerKey = flowFunctionKey(name, "onTrigger"); | ||
return Object.assign(Object.assign({}, result), { [triggerKey]: convertTrigger(triggerKey, { | ||
display: { | ||
label: `${name} - onTrigger`, | ||
description: "The function that will be executed by the flow to return an HTTP response.", | ||
}, | ||
perform: onTrigger, | ||
onInstanceDeploy: onInstanceDeploy, | ||
onInstanceDelete: onInstanceDelete, | ||
inputs: {}, | ||
scheduleSupport: "valid", | ||
synchronousResponseSupport: "valid", | ||
}) }); | ||
}, {}); | ||
const convertedDataSources = Object.entries(dataSources).reduce((result, [dataSourceKey, dataSource]) => (Object.assign(Object.assign({}, result), { [dataSourceKey]: convertDataSource(dataSourceKey, Object.assign(Object.assign({}, dataSource), { inputs: {} })) })), {}); | ||
const convertedConnections = Object.entries(configVars).reduce((result, [key, configVar]) => { | ||
if (!("label" in configVar)) { | ||
return result; | ||
} | ||
// Remove a few fields that are not relevant to connections. | ||
const { | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
orgOnly, visibleToOrgDeployer, visibleToCustomerDeployer } = configVar, | ||
/* eslint-enable @typescript-eslint/no-unused-vars */ | ||
connection = __rest(configVar, ["orgOnly", "visibleToOrgDeployer", "visibleToCustomerDeployer"]); | ||
return [...result, convertConnection(Object.assign(Object.assign({}, connection), { key }))]; | ||
}, []); | ||
return { | ||
key: referenceKey, | ||
display: { | ||
label: referenceKey, | ||
iconPath, | ||
description: description || name, | ||
}, | ||
connections: convertedConnections, | ||
actions: convertedActions, | ||
triggers: convertedTriggers, | ||
dataSources: convertedDataSources, | ||
}; | ||
}; |
/// <reference types="node" /> | ||
import { Instance, Customer, DataSourceType, DataSourceResultType, User, TriggerEventFunctionReturn, Integration, Flow } from "../types"; | ||
import { InstanceAttributes, CustomerAttributes, DataSourceType, DataSourceResultType, UserAttributes, TriggerEventFunctionReturn, IntegrationAttributes, FlowAttributes, ConfigVarResultCollection } from "../types"; | ||
interface DisplayDefinition { | ||
@@ -7,7 +7,7 @@ label: string; | ||
} | ||
export { Instance } from "../types"; | ||
export { Customer } from "../types"; | ||
export { User } from "../types"; | ||
export { Integration } from "../types"; | ||
export { Flow } from "../types"; | ||
export { InstanceAttributes } from "../types"; | ||
export { CustomerAttributes } from "../types"; | ||
export { UserAttributes } from "../types"; | ||
export { IntegrationAttributes } from "../types"; | ||
export { FlowAttributes } from "../types"; | ||
export interface Component { | ||
@@ -25,2 +25,3 @@ key: string; | ||
connections: Connection[]; | ||
codeNativeIntegrationYAML?: string; | ||
} | ||
@@ -52,3 +53,3 @@ export interface Action { | ||
} | ||
export interface ActionContext { | ||
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection, THasConfigVars extends boolean = false> = { | ||
logger: ActionLogger; | ||
@@ -64,9 +65,11 @@ instanceState: Record<string, unknown>; | ||
invokeUrl: string; | ||
customer: Customer; | ||
instance: Instance; | ||
user: User; | ||
integration: Integration; | ||
flow: Flow; | ||
customer: CustomerAttributes; | ||
instance: InstanceAttributes; | ||
user: UserAttributes; | ||
integration: IntegrationAttributes; | ||
flow: FlowAttributes; | ||
startedAt: string; | ||
} | ||
} & (THasConfigVars extends true ? { | ||
configVars: TConfigVars; | ||
} : Record<string, never>); | ||
declare type TriggerOptionChoice = "invalid" | "valid" | "required"; | ||
@@ -89,7 +92,7 @@ export interface TriggerPayload { | ||
executionId: string; | ||
customer: Customer; | ||
instance: Instance; | ||
user: User; | ||
integration: Integration; | ||
flow: Flow; | ||
customer: CustomerAttributes; | ||
instance: InstanceAttributes; | ||
user: UserAttributes; | ||
integration: IntegrationAttributes; | ||
flow: FlowAttributes; | ||
startedAt: string; | ||
@@ -117,5 +120,5 @@ } | ||
export declare type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined; | ||
export declare type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>; | ||
export declare type TriggerPerformFunction = (context: ActionContext<any>, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>; | ||
export declare type TriggerEventFunctionResult = TriggerEventFunctionReturn | void; | ||
export declare type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>; | ||
export declare type TriggerEventFunction = (context: ActionContext<any>, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>; | ||
export interface Trigger { | ||
@@ -145,5 +148,5 @@ key: string; | ||
logger: ActionLogger; | ||
customer: Customer; | ||
instance: Instance; | ||
user: User; | ||
customer: CustomerAttributes; | ||
instance: InstanceAttributes; | ||
user: UserAttributes; | ||
} | ||
@@ -221,3 +224,3 @@ export declare type DataSourceResult = { | ||
export declare type ActionPerformReturn = ServerPerformDataStructureReturn | ServerPerformBranchingDataStructureReturn | ServerPerformDataReturn | ServerPerformBranchingDataReturn | undefined; | ||
export declare type ActionPerformFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<ActionPerformReturn>; | ||
export declare type ActionPerformFunction = (context: ActionContext<any>, params: Record<string, unknown>) => Promise<ActionPerformReturn>; | ||
interface InputFieldChoice { | ||
@@ -224,0 +227,0 @@ label: string; |
@@ -8,3 +8,3 @@ /** | ||
import { TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn, DataSourceResult, DataSourceContext } from "./serverTypes"; | ||
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn } from "./types"; | ||
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection, ConfigVarCollection, ConfigVarDefinitionsToResults } from "./types"; | ||
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown> | undefined) => ConnectionValue; | ||
@@ -29,3 +29,3 @@ /** | ||
*/ | ||
export declare const invoke: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform }: ActionDefinition<TInputs, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<TReturn>>; | ||
export declare const invoke: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform, }: ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext<TConfigVars, false>> | undefined) => Promise<InvokeReturn<TReturn>>; | ||
export declare const defaultTriggerPayload: () => TriggerPayload; | ||
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
export declare const invokeTrigger: <TInputs extends Inputs, TAllowsBranching extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching>>({ perform }: TriggerDefinition<TInputs, TAllowsBranching, TResult>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs> | undefined) => Promise<InvokeReturn<TResult>>; | ||
export declare const invokeTrigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TriggerPayload>>({ perform, }: TriggerDefinition<TInputs, TConfigVars, TAllowsBranching, TResult>, context?: Partial<ActionContext<TConfigVars, false>> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs> | undefined) => Promise<InvokeReturn<TResult>>; | ||
/** | ||
@@ -62,2 +62,7 @@ * Invokes specified DataSourceDefinition perform function using supplied params. | ||
}>({ perform }: DataSourceDefinition<TInputs, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext> | undefined) => Promise<InvokeDataSourceResult<TDataSourceType>>; | ||
/** | ||
* Invokes specified Flow of a Code Native Integration using supplied params. | ||
* Runs the Trigger and then the Action function and returns the result of the Action. | ||
*/ | ||
export declare const invokeFlow: <TConfigVars extends ConfigVarCollection>(flow: Flow<TConfigVars, import("./types").TriggerPayload>, context?: Partial<ActionContext<ConfigVarDefinitionsToResults<TConfigVars>, true>> | undefined, payload?: TriggerPayload | undefined) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>; | ||
export declare class ComponentTestHarness<TComponent extends Component> { | ||
@@ -69,6 +74,6 @@ component: TComponent; | ||
connectionValue({ key }: ConnectionDefinition): ConnectionValue; | ||
trigger(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<TriggerResult>; | ||
triggerOnInstanceDeploy(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<void | TriggerEventFunctionReturn>; | ||
triggerOnInstanceDelete(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<void | TriggerEventFunctionReturn>; | ||
action(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<ActionPerformReturn>; | ||
trigger<TConfigVars extends ConfigVarResultCollection>(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerResult>; | ||
triggerOnInstanceDeploy<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<void | TriggerEventFunctionReturn>; | ||
triggerOnInstanceDelete<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<void | TriggerEventFunctionReturn>; | ||
action<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<ActionPerformReturn>; | ||
dataSource(key: string, params?: Record<string, unknown>, context?: Partial<DataSourceContext>): Promise<DataSourceResult>; | ||
@@ -79,4 +84,4 @@ } | ||
loggerMock: () => ActionLogger; | ||
invoke: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform }: ActionDefinition<TInputs, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<TReturn>>; | ||
invokeTrigger: <TInputs_1 extends Inputs, TAllowsBranching_1 extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching_1>>({ perform }: TriggerDefinition<TInputs_1, TAllowsBranching_1, TResult>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs_1> | undefined) => Promise<InvokeReturn<TResult>>; | ||
invoke: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform, }: ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext<TConfigVars, false>> | undefined) => Promise<InvokeReturn<TReturn>>; | ||
invokeTrigger: <TInputs_1 extends Inputs, TConfigVars_1 extends ConfigVarResultCollection, TAllowsBranching_1 extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching_1, TriggerPayload>>({ perform, }: TriggerDefinition<TInputs_1, TConfigVars_1, TAllowsBranching_1, TResult>, context?: Partial<ActionContext<TConfigVars_1, false>> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs_1> | undefined) => Promise<InvokeReturn<TResult>>; | ||
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>; | ||
@@ -83,0 +88,0 @@ invokeDataSource: <TInputs_2 extends Inputs, TDataSourceType extends keyof { |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createHarness = exports.ComponentTestHarness = exports.invokeDataSource = exports.invokeTrigger = exports.defaultTriggerPayload = exports.invoke = exports.loggerMock = exports.createConnection = void 0; | ||
exports.createHarness = exports.ComponentTestHarness = exports.invokeFlow = exports.invokeDataSource = exports.invokeTrigger = exports.defaultTriggerPayload = exports.invoke = exports.loggerMock = exports.createConnection = void 0; | ||
const jest_mock_1 = require("jest-mock"); | ||
@@ -42,42 +42,28 @@ const createConnection = ({ key }, values, tokenValues) => ({ | ||
exports.loggerMock = loggerMock; | ||
const baseActionContext = { | ||
logger: (0, exports.loggerMock)(), | ||
instanceState: {}, | ||
crossFlowState: {}, | ||
executionState: {}, | ||
integrationState: {}, | ||
stepId: "mockStepId", | ||
executionId: "mockExecutionId", | ||
webhookUrls: { | ||
"Flow 1": "https://example.com", | ||
}, | ||
webhookApiKeys: { | ||
"Flow 1": ["example-123", "example-456"], | ||
}, | ||
invokeUrl: "https://example.com", | ||
customer: { | ||
id: "customerId", | ||
name: "Customer 1", | ||
externalId: "1234", | ||
}, | ||
instance: { | ||
id: "instanceId", | ||
name: "Instance 1", | ||
}, | ||
user: { | ||
id: "userId", | ||
email: "user@example.com", | ||
name: "User 1", | ||
externalId: "1234", | ||
}, | ||
integration: { | ||
id: "integrationId", | ||
name: "Integration 1", | ||
versionSequenceId: "1234", | ||
}, | ||
flow: { | ||
id: "flowId", | ||
name: "Flow 1", | ||
}, | ||
startedAt: new Date().toISOString(), | ||
const createActionContext = (context) => { | ||
return Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, integrationState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: { | ||
"Flow 1": "https://example.com", | ||
}, webhookApiKeys: { | ||
"Flow 1": ["example-123", "example-456"], | ||
}, invokeUrl: "https://example.com", customer: { | ||
id: "customerId", | ||
name: "Customer 1", | ||
externalId: "1234", | ||
}, instance: { | ||
id: "instanceId", | ||
name: "Instance 1", | ||
}, user: { | ||
id: "userId", | ||
email: "user@example.com", | ||
name: "User 1", | ||
externalId: "1234", | ||
}, integration: { | ||
id: "integrationId", | ||
name: "Integration 1", | ||
versionSequenceId: "1234", | ||
externalVersion: "1.0.0", | ||
}, flow: { | ||
id: "flowId", | ||
name: "Flow 1", | ||
}, startedAt: new Date().toISOString() }, context); | ||
}; | ||
@@ -90,4 +76,4 @@ /** | ||
*/ | ||
const invoke = ({ perform }, params, context) => __awaiter(void 0, void 0, void 0, function* () { | ||
const realizedContext = Object.assign(Object.assign({}, baseActionContext), context); | ||
const invoke = ({ perform, }, params, context) => __awaiter(void 0, void 0, void 0, function* () { | ||
const realizedContext = createActionContext(context); | ||
const result = yield perform(realizedContext, params); | ||
@@ -144,2 +130,3 @@ return { | ||
versionSequenceId: "1234", | ||
externalVersion: "1.0.0", | ||
}, | ||
@@ -160,4 +147,4 @@ flow: { | ||
*/ | ||
const invokeTrigger = ({ perform }, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () { | ||
const realizedContext = Object.assign(Object.assign({}, baseActionContext), context); | ||
const invokeTrigger = ({ perform, }, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () { | ||
const realizedContext = createActionContext(context); | ||
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload); | ||
@@ -201,2 +188,23 @@ const realizedParams = params || {}; | ||
exports.invokeDataSource = invokeDataSource; | ||
/** | ||
* Invokes specified Flow of a Code Native Integration using supplied params. | ||
* Runs the Trigger and then the Action function and returns the result of the Action. | ||
*/ | ||
const invokeFlow = (flow, context, payload) => __awaiter(void 0, void 0, void 0, function* () { | ||
const realizedContext = createActionContext(context); | ||
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload); | ||
const params = { | ||
onTrigger: { results: null }, | ||
}; | ||
if ("onTrigger" in flow) { | ||
const triggerResult = yield flow.onTrigger(realizedContext, realizedPayload, params); | ||
params.onTrigger = { results: triggerResult === null || triggerResult === void 0 ? void 0 : triggerResult.payload }; | ||
} | ||
const result = yield flow.onExecution(realizedContext, params); | ||
return { | ||
result, | ||
loggerMock: realizedContext.logger, | ||
}; | ||
}); | ||
exports.invokeFlow = invokeFlow; | ||
class ComponentTestHarness { | ||
@@ -224,3 +232,3 @@ constructor(component) { | ||
const trigger = this.component.triggers[key]; | ||
return trigger.perform(this.buildContext(baseActionContext, context), Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), this.buildParams(trigger.inputs, params)); | ||
return trigger.perform(createActionContext(context), Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), this.buildParams(trigger.inputs, params)); | ||
}); | ||
@@ -234,3 +242,3 @@ } | ||
} | ||
return trigger.onInstanceDeploy(this.buildContext(baseActionContext, context), this.buildParams(trigger.inputs, params)); | ||
return trigger.onInstanceDeploy(createActionContext(context), this.buildParams(trigger.inputs, params)); | ||
}); | ||
@@ -244,3 +252,3 @@ } | ||
} | ||
return trigger.onInstanceDelete(this.buildContext(baseActionContext, context), this.buildParams(trigger.inputs, params)); | ||
return trigger.onInstanceDelete(createActionContext(context), this.buildParams(trigger.inputs, params)); | ||
}); | ||
@@ -251,3 +259,3 @@ } | ||
const action = this.component.actions[key]; | ||
return action.perform(this.buildContext(baseActionContext, context), this.buildParams(action.inputs, params)); | ||
return action.perform(createActionContext(context), this.buildParams(action.inputs, params)); | ||
}); | ||
@@ -254,0 +262,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ActionDisplayDefinition, ActionPerformFunction, ActionPerformReturn, Inputs } from "."; | ||
import { ActionDisplayDefinition, ActionPerformFunction, ActionPerformReturn, ConfigVarResultCollection, Inputs } from "."; | ||
/** | ||
@@ -6,7 +6,7 @@ * ActionDefinition is the type of the object that is passed in to `action` function to | ||
*/ | ||
export interface ActionDefinition<TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> { | ||
export interface ActionDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown> = ActionPerformReturn<TAllowsBranching, unknown>> { | ||
/** Defines how the Action is displayed in the Prismatic interface. */ | ||
display: ActionDisplayDefinition; | ||
/** Function to perform when this Action is invoked. */ | ||
perform: ActionPerformFunction<TInputs, TAllowsBranching, TReturn>; | ||
perform: ActionPerformFunction<TInputs, TConfigVars, false, TAllowsBranching, TReturn>; | ||
/** InputFields to present in the Prismatic interface for configuration of this Action. */ | ||
@@ -13,0 +13,0 @@ inputs: TInputs; |
@@ -1,6 +0,6 @@ | ||
import { Inputs, ActionPerformReturn, ActionInputParameters, ActionLogger, Instance, Customer, User, Integration, Flow } from "."; | ||
import { Inputs, ConfigVarResultCollection, ActionPerformReturn, ActionInputParameters, ActionLogger, InstanceAttributes, CustomerAttributes, UserAttributes, IntegrationAttributes, FlowAttributes } from "."; | ||
/** Definition of the function to perform when an Action is invoked. */ | ||
export declare type ActionPerformFunction<TInputs extends Inputs, TAllowsBranching extends boolean | undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext, params: ActionInputParameters<TInputs>) => Promise<TReturn>; | ||
export declare type ActionPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, THasConfigVars extends boolean, TAllowsBranching extends boolean | undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext<TConfigVars, THasConfigVars>, params: ActionInputParameters<TInputs>) => Promise<TReturn>; | ||
/** Context provided to perform method containing helpers and contextual data */ | ||
export interface ActionContext { | ||
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, THasConfigVars extends boolean = false> = { | ||
/** Logger for permanent logging; console calls are also captured */ | ||
@@ -27,13 +27,16 @@ logger: ActionLogger; | ||
/** Contains attributes of the Customer for whom an Instance is being executed. */ | ||
customer: Customer; | ||
customer: CustomerAttributes; | ||
/** Contains attributes of the Instance that is being executed. */ | ||
instance: Instance; | ||
instance: InstanceAttributes; | ||
/** Contains attributes of the User for whom a User Level Configuration is being used. */ | ||
user: User; | ||
user: UserAttributes; | ||
/** Contains attributes of the Integration that is being executed. */ | ||
integration: Integration; | ||
integration: IntegrationAttributes; | ||
/** Contains attributes of the Flow that is being executed. */ | ||
flow: Flow; | ||
flow: FlowAttributes; | ||
/** The time in UTC that execution started. */ | ||
startedAt: string; | ||
} | ||
} & (THasConfigVars extends true ? { | ||
/** Key/value collection of config variables of the integration. */ | ||
configVars: TConfigVars; | ||
} : Record<string, never>); |
@@ -16,5 +16,5 @@ import { ActionDefinition, ConnectionDefinition, ComponentDisplayDefinition, TriggerDefinition, DataSourceDefinition } from "."; | ||
/** Specifies the supported Actions of this Component. */ | ||
actions?: Record<string, ActionDefinition<any, boolean, any>>; | ||
actions?: Record<string, ActionDefinition<any, any, boolean, any>>; | ||
/** Specifies the supported Triggers of this Component. */ | ||
triggers?: Record<string, TriggerDefinition<any, boolean, any>>; | ||
triggers?: Record<string, TriggerDefinition<any, any, boolean, any>>; | ||
/** Specifies the supported Data Sources of this Component. */ | ||
@@ -21,0 +21,0 @@ dataSources?: Record<string, DataSourceDefinition<any, any>>; |
@@ -1,10 +0,10 @@ | ||
import { Inputs, DataSourceResult, DataSourceType, ActionInputParameters, ActionLogger, Customer, Instance, User } from "."; | ||
import { Inputs, DataSourceResult, DataSourceType, ActionInputParameters, ActionLogger, CustomerAttributes, InstanceAttributes, UserAttributes } from "."; | ||
/** Context provided to perform method containing helpers and contextual data */ | ||
export interface DataSourceContext { | ||
logger: ActionLogger; | ||
customer: Customer; | ||
instance: Instance; | ||
user: User; | ||
customer: CustomerAttributes; | ||
instance: InstanceAttributes; | ||
user: UserAttributes; | ||
} | ||
/** Definition of the function to perform when a Data Source is invoked. */ | ||
export declare type DataSourcePerformFunction<TInputs extends Inputs, TDataSourceType extends DataSourceType> = (context: DataSourceContext, params: ActionInputParameters<TInputs>) => Promise<DataSourceResult<TDataSourceType>>; |
@@ -25,7 +25,8 @@ /** | ||
export * from "./DataSourceResult"; | ||
export * from "./Instance"; | ||
export * from "./Customer"; | ||
export * from "./User"; | ||
export * from "./Integration"; | ||
export * from "./Flow"; | ||
export * from "./InstanceAttributes"; | ||
export * from "./CustomerAttributes"; | ||
export * from "./UserAttributes"; | ||
export * from "./IntegrationAttributes"; | ||
export * from "./FlowAttributes"; | ||
export * from "./IntegrationDefinition"; | ||
export * as serverTypes from "../serverTypes"; |
@@ -54,7 +54,8 @@ "use strict"; | ||
__exportStar(require("./DataSourceResult"), exports); | ||
__exportStar(require("./Instance"), exports); | ||
__exportStar(require("./Customer"), exports); | ||
__exportStar(require("./User"), exports); | ||
__exportStar(require("./Integration"), exports); | ||
__exportStar(require("./Flow"), exports); | ||
__exportStar(require("./InstanceAttributes"), exports); | ||
__exportStar(require("./CustomerAttributes"), exports); | ||
__exportStar(require("./UserAttributes"), exports); | ||
__exportStar(require("./IntegrationAttributes"), exports); | ||
__exportStar(require("./FlowAttributes"), exports); | ||
__exportStar(require("./IntegrationDefinition"), exports); | ||
exports.serverTypes = __importStar(require("../serverTypes")); |
@@ -242,2 +242,4 @@ import { ConditionalExpression } from "./conditional-logic"; | ||
export declare type InputFieldCollection = "valuelist" | "keyvaluelist"; | ||
/** Config variable result collection */ | ||
export declare type ConfigVarResultCollection = Record<string, string | Connection | JSONForm | ObjectSelection>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import { ActionDisplayDefinition, TriggerPerformFunction, TriggerEventFunction, Inputs, TriggerResult } from "."; | ||
import { ActionDisplayDefinition, TriggerPerformFunction, TriggerEventFunction, Inputs, TriggerResult, ConfigVarResultCollection, TriggerPayload } from "."; | ||
declare const optionChoices: readonly ["invalid", "valid", "required"]; | ||
@@ -9,11 +9,11 @@ export declare type TriggerOptionChoice = typeof optionChoices[number]; | ||
*/ | ||
export interface TriggerDefinition<TInputs extends Inputs, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching>> { | ||
export interface TriggerDefinition<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>> { | ||
/** Defines how the Trigger is displayed in the Prismatic interface. */ | ||
display: ActionDisplayDefinition; | ||
/** Function to perform when this Trigger is invoked. */ | ||
perform: TriggerPerformFunction<TInputs, TAllowsBranching, TResult>; | ||
perform: TriggerPerformFunction<TInputs, TConfigVars, false, TAllowsBranching, TResult>; | ||
/** Function to execute when an Instance of an Integration with a Flow that uses this Trigger is deployed. */ | ||
onInstanceDeploy?: TriggerEventFunction<TInputs>; | ||
onInstanceDeploy?: TriggerEventFunction<TInputs, TConfigVars, false>; | ||
/** Function to execute when an Instance of an Integration with a Flow that uses this Trigger is deleted. */ | ||
onInstanceDelete?: TriggerEventFunction<TInputs>; | ||
onInstanceDelete?: TriggerEventFunction<TInputs, TConfigVars, false>; | ||
/** InputFields to present in the Prismatic interface for configuration of this Trigger. */ | ||
@@ -20,0 +20,0 @@ inputs: TInputs; |
@@ -1,2 +0,2 @@ | ||
import { Inputs, ActionContext, ActionInputParameters } from "."; | ||
import { Inputs, ActionContext, ActionInputParameters, ConfigVarResultCollection } from "."; | ||
export declare type TriggerEventFunctionReturn = { | ||
@@ -13,2 +13,2 @@ /** An optional object, the keys and values of which will be persisted in the flow-specific instanceState and available for subsequent actions and executions */ | ||
/** Definition of the function to execute when a Trigger Event occurs. */ | ||
export declare type TriggerEventFunction<TInputs extends Inputs> = (context: ActionContext, params: ActionInputParameters<TInputs>) => Promise<void | TriggerEventFunctionReturn>; | ||
export declare type TriggerEventFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, THasConfigVars extends boolean> = (context: ActionContext<TConfigVars, THasConfigVars>, params: ActionInputParameters<TInputs>) => Promise<void | TriggerEventFunctionReturn>; |
@@ -1,2 +0,2 @@ | ||
import { Instance, Customer, User, Integration, Flow } from "."; | ||
import { InstanceAttributes, CustomerAttributes, UserAttributes, IntegrationAttributes, FlowAttributes } from "."; | ||
/** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution. */ | ||
@@ -32,13 +32,13 @@ export interface TriggerPayload { | ||
/** Contains attributes of the Customer for whom an Instance is being executed. */ | ||
customer: Customer; | ||
customer: CustomerAttributes; | ||
/** Contains attributes of the Instance that is being executed. */ | ||
instance: Instance; | ||
instance: InstanceAttributes; | ||
/** Contains attributes of the User for whom a User Level Configuration is being used. */ | ||
user: User; | ||
user: UserAttributes; | ||
/** Contains attributes of the Integration that is being executed. */ | ||
integration: Integration; | ||
integration: IntegrationAttributes; | ||
/** Contains attributes of the Flow that is being executed. */ | ||
flow: Flow; | ||
flow: FlowAttributes; | ||
/** The time in UTC that execution started. */ | ||
startedAt: string; | ||
} |
@@ -1,3 +0,3 @@ | ||
import { Inputs, TriggerResult, ActionInputParameters, ActionContext, TriggerPayload } from "."; | ||
import { Inputs, TriggerResult, ActionInputParameters, ActionContext, TriggerPayload, ConfigVarResultCollection } from "."; | ||
/** Definition of the function to perform when a Trigger is invoked. */ | ||
export declare type TriggerPerformFunction<T extends Inputs, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching>> = (context: ActionContext, payload: TriggerPayload, params: ActionInputParameters<T>) => Promise<TResult>; | ||
export declare type TriggerPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, THasConfigVars extends boolean, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>> = (context: ActionContext<TConfigVars, THasConfigVars>, payload: TriggerPayload, params: ActionInputParameters<TInputs>) => Promise<TResult>; |
import { TriggerPayload } from "./TriggerPayload"; | ||
import { HttpResponse } from "./HttpResponse"; | ||
/** Represents the result of a Trigger action. */ | ||
export interface TriggerBaseResult { | ||
export interface TriggerBaseResult<TPayload extends TriggerPayload> { | ||
/** The payload in the request that invoked the Integration, which is returned as a result for later use. */ | ||
payload: TriggerPayload; | ||
payload: TPayload; | ||
/** Optional HTTP response to the request that invoked the integration. */ | ||
@@ -23,3 +23,3 @@ response?: HttpResponse; | ||
/** Represents the result of a Trigger action that uses branching. */ | ||
export interface TriggerBranchingResult extends TriggerBaseResult { | ||
export interface TriggerBranchingResult<TPayload extends TriggerPayload> extends TriggerBaseResult<TPayload> { | ||
/** Name of the Branch to take. */ | ||
@@ -29,2 +29,2 @@ branch: string; | ||
/** Required return type of all trigger perform functions */ | ||
export declare type TriggerResult<AllowsBranching extends boolean | undefined> = (AllowsBranching extends true ? TriggerBranchingResult : TriggerBaseResult) | undefined; | ||
export declare type TriggerResult<AllowsBranching extends boolean | undefined, TPayload extends TriggerPayload> = (AllowsBranching extends true ? TriggerBranchingResult<TPayload> : TriggerBaseResult<TPayload>) | undefined; |
{ | ||
"name": "@prismatic-io/spectral", | ||
"version": "7.9.0", | ||
"version": "8.0.0-preview10", | ||
"description": "Utility library for building Prismatic components", | ||
@@ -41,4 +41,4 @@ "keywords": [ | ||
"@jsonforms/core": "3.0.0", | ||
"axios": "1.6.2", | ||
"axios-retry": "3.9.1", | ||
"axios": "0.27.2", | ||
"axios-retry": "3.2.5", | ||
"date-fns": "2.30.0", | ||
@@ -49,5 +49,7 @@ "form-data": "4.0.0", | ||
"serialize-error": "8.1.0", | ||
"soap": "1.0.0", | ||
"url-join": "5.0.0", | ||
"uuid": "8.3.2", | ||
"valid-url": "1.0.9" | ||
"valid-url": "1.0.9", | ||
"yaml": "2.3.4" | ||
}, | ||
@@ -54,0 +56,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
218253
85
4702
13
1
2
+ Addedsoap@1.0.0
+ Addedyaml@2.3.4
+ Added@xmldom/xmldom@0.8.10(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedaxios@0.27.21.7.7(transitive)
+ Addedaxios-ntlm@1.4.2(transitive)
+ Addedaxios-retry@3.2.5(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddes.js@1.1.0(transitive)
+ Addeddev-null@0.1.1(transitive)
+ Addeddezalgo@1.0.4(transitive)
+ Addedformidable@3.5.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhexoid@1.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedjs-md4@0.3.2(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsoap@1.0.0(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedwhatwg-mimetype@3.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxml-crypto@3.2.0(transitive)
+ Addedxpath@0.0.32(transitive)
+ Addedyaml@2.3.4(transitive)
- Removedaxios@1.6.2(transitive)
- Removedaxios-retry@3.9.1(transitive)
Updatedaxios@0.27.2
Updatedaxios-retry@3.2.5