@prismatic-io/spectral 8.0.0 → 8.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -9
- package/dist/index.js +11 -2
- package/dist/serverTypes/convert.d.ts +3 -3
- package/dist/serverTypes/convert.js +6 -254
- package/dist/serverTypes/convertIntegration.d.ts +3 -0
- package/dist/serverTypes/convertIntegration.js +247 -0
- package/dist/serverTypes/index.d.ts +8 -8
- package/dist/serverTypes/integration.d.ts +60 -0
- package/dist/serverTypes/integration.js +4 -0
- package/dist/testing.d.ts +16 -16
- package/dist/testing.js +30 -26
- package/dist/types/ActionDefinition.d.ts +1 -1
- package/dist/types/ActionPerformFunction.d.ts +5 -6
- package/dist/types/ComponentDefinition.d.ts +1 -1
- package/dist/types/DataSourceDefinition.d.ts +3 -3
- package/dist/types/DataSourcePerformFunction.d.ts +3 -8
- package/dist/types/DataSourceResult.d.ts +1 -3
- package/dist/types/Inputs.d.ts +6 -1
- package/dist/types/IntegrationDefinition.d.ts +31 -86
- package/dist/types/IntegrationDefinition.js +5 -19
- package/dist/types/TriggerDefinition.d.ts +3 -3
- package/dist/types/TriggerEventFunction.d.ts +1 -1
- package/dist/types/TriggerPerformFunction.d.ts +1 -1
- package/dist/types/utils.d.ts +5 -0
- package/dist/types/utils.js +2 -0
- package/package.json +3 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertIntegration = void 0;
|
|
7
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const convert_1 = require("./convert");
|
|
12
|
+
const integration_1 = require("./integration");
|
|
13
|
+
const convertIntegration = (definition) => {
|
|
14
|
+
var _a;
|
|
15
|
+
// Generate a unique reference key that will be used to reference the
|
|
16
|
+
// actions, triggers, data sources, and connections that are created
|
|
17
|
+
// inline as part of the integration definition.
|
|
18
|
+
const referenceKey = (0, uuid_1.v4)();
|
|
19
|
+
const configVars = Object.assign({}, ...Object.values((_a = definition.configPages) !== null && _a !== void 0 ? _a : {}).map(({ elements }) => elements));
|
|
20
|
+
return Object.assign(Object.assign({}, codeNativeIntegrationComponent(definition, referenceKey, configVars)), { codeNativeIntegrationYAML: codeNativeIntegrationYaml(definition, referenceKey, configVars) });
|
|
21
|
+
};
|
|
22
|
+
exports.convertIntegration = convertIntegration;
|
|
23
|
+
const convertConfigPages = (pages) => {
|
|
24
|
+
if (!pages || !Object.keys(pages).length) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
return Object.entries(pages).map(([name, { tagline, elements }]) => ({
|
|
28
|
+
name,
|
|
29
|
+
tagline,
|
|
30
|
+
elements: Object.keys(elements).map((key) => ({
|
|
31
|
+
type: "configVar",
|
|
32
|
+
value: key,
|
|
33
|
+
})),
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, }, referenceKey, configVars) => {
|
|
37
|
+
// Find the preprocess flow config on the flow, if one exists.
|
|
38
|
+
const preprocessFlows = flows.filter((flow) => flow.preprocessFlowConfig);
|
|
39
|
+
// Do some validation of preprocess flow configs.
|
|
40
|
+
if (preprocessFlows.length > 1) {
|
|
41
|
+
throw new Error("Only one flow may define a Preprocess Flow Config.");
|
|
42
|
+
}
|
|
43
|
+
if (preprocessFlows.length && triggerPreprocessFlowConfig) {
|
|
44
|
+
throw new Error("Integration must not define both a Trigger Preprocess Flow Config and a Preprocess Flow.");
|
|
45
|
+
}
|
|
46
|
+
const hasPreprocessFlow = preprocessFlows.length > 0;
|
|
47
|
+
const preprocessFlowConfig = hasPreprocessFlow
|
|
48
|
+
? preprocessFlows[0].preprocessFlowConfig
|
|
49
|
+
: triggerPreprocessFlowConfig;
|
|
50
|
+
if ([types_1.EndpointType.InstanceSpecific, types_1.EndpointType.SharedInstance].includes(endpointType || types_1.EndpointType.FlowSpecific) &&
|
|
51
|
+
!preprocessFlowConfig) {
|
|
52
|
+
throw new Error("Integration with specified EndpointType must define either a Trigger Preprocess Flow Config or a Preprocess Flow.");
|
|
53
|
+
}
|
|
54
|
+
// Transform the IntegrationDefinition into the structure that is appropriate
|
|
55
|
+
// for generating YAML, which will then be used by the Prismatic API to import
|
|
56
|
+
// the integration as a Code Native Integration.
|
|
57
|
+
const result = {
|
|
58
|
+
definitionVersion: integration_1.DefinitionVersion,
|
|
59
|
+
isCodeNative: true,
|
|
60
|
+
name,
|
|
61
|
+
description,
|
|
62
|
+
category,
|
|
63
|
+
documentation,
|
|
64
|
+
version,
|
|
65
|
+
labels,
|
|
66
|
+
requiredConfigVars: Object.entries(configVars || {}).map(([key, configVar]) => convertConfigVar(key, configVar, referenceKey)),
|
|
67
|
+
endpointType,
|
|
68
|
+
preprocessFlowName: hasPreprocessFlow ? preprocessFlows[0].name : undefined,
|
|
69
|
+
externalCustomerIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerIdField),
|
|
70
|
+
externalCustomerUserIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerUserIdField),
|
|
71
|
+
flowNameField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.flowNameField),
|
|
72
|
+
flows: flows.map((flow) => convertFlow(flow, referenceKey)),
|
|
73
|
+
configPages: convertConfigPages(configPages !== null && configPages !== void 0 ? configPages : {}),
|
|
74
|
+
};
|
|
75
|
+
return yaml_1.default.stringify(result);
|
|
76
|
+
};
|
|
77
|
+
/** Converts a Flow into the structure necessary for YAML generation. */
|
|
78
|
+
const convertFlow = (flow, referenceKey) => {
|
|
79
|
+
const result = Object.assign({}, flow);
|
|
80
|
+
delete result.onTrigger;
|
|
81
|
+
delete result.trigger;
|
|
82
|
+
delete result.onInstanceDeploy;
|
|
83
|
+
delete result.onInstanceDelete;
|
|
84
|
+
delete result.onExecution;
|
|
85
|
+
delete result.preprocessFlowConfig;
|
|
86
|
+
delete result.errorConfig;
|
|
87
|
+
const triggerStep = {
|
|
88
|
+
name: "On Trigger",
|
|
89
|
+
stableKey: `${flow.stableKey}-onTrigger`,
|
|
90
|
+
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
91
|
+
isTrigger: true,
|
|
92
|
+
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined,
|
|
93
|
+
action: {
|
|
94
|
+
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
95
|
+
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
if ("schedule" in flow && typeof flow.schedule === "object") {
|
|
99
|
+
triggerStep.schedule = {
|
|
100
|
+
type: "cronExpression" in flow.schedule ? "value" : "configVar",
|
|
101
|
+
value: "cronExpression" in flow.schedule
|
|
102
|
+
? flow.schedule.cronExpression
|
|
103
|
+
: flow.schedule.configVarKey,
|
|
104
|
+
meta: {
|
|
105
|
+
scheduleType: types_1.ScheduleType.Custom,
|
|
106
|
+
timeZone: flow.schedule.timeZone,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
delete result.schedule;
|
|
110
|
+
}
|
|
111
|
+
const actionStep = {
|
|
112
|
+
action: {
|
|
113
|
+
key: flowFunctionKey(flow.name, "onExecution"),
|
|
114
|
+
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
115
|
+
},
|
|
116
|
+
name: "On Execution",
|
|
117
|
+
stableKey: `${flow.stableKey}-onExecution`,
|
|
118
|
+
description: "The function that will be executed by the flow.",
|
|
119
|
+
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined,
|
|
120
|
+
};
|
|
121
|
+
result.steps = [triggerStep, actionStep];
|
|
122
|
+
return result;
|
|
123
|
+
};
|
|
124
|
+
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
125
|
+
const convertConfigVar = (key, configVar, referenceKey) => {
|
|
126
|
+
const meta = (0, lodash_1.pick)(configVar, [
|
|
127
|
+
"visibleToCustomerDeployer",
|
|
128
|
+
"visibleToOrgDeployer",
|
|
129
|
+
]);
|
|
130
|
+
if ((0, types_1.isConnectionConfigVar)(configVar)) {
|
|
131
|
+
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: {
|
|
132
|
+
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
133
|
+
key: (0, lodash_1.camelCase)(key),
|
|
134
|
+
}, inputs: Object.entries(configVar.inputs).reduce((result, [key, input]) => {
|
|
135
|
+
if (!input.shown || !input.default) {
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
return Object.assign(Object.assign({}, result), { [key]: { type: "value", value: input.default } });
|
|
139
|
+
}, {}), meta });
|
|
140
|
+
}
|
|
141
|
+
const result = (0, lodash_1.assign)({ meta, key }, (0, lodash_1.pick)(configVar, [
|
|
142
|
+
"stableKey",
|
|
143
|
+
"description",
|
|
144
|
+
"orgOnly",
|
|
145
|
+
"defaultValue",
|
|
146
|
+
"dataType",
|
|
147
|
+
"pickList",
|
|
148
|
+
"scheduleType",
|
|
149
|
+
"timeZone",
|
|
150
|
+
"codeLanguage",
|
|
151
|
+
"collectionType",
|
|
152
|
+
]));
|
|
153
|
+
// Handle data sources.
|
|
154
|
+
if ((0, types_1.isDataSourceConfigVar)(configVar)) {
|
|
155
|
+
result.dataType = configVar.dataSourceType;
|
|
156
|
+
result.dataSource = {
|
|
157
|
+
key: (0, lodash_1.camelCase)(key),
|
|
158
|
+
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
};
|
|
163
|
+
/** Maps the step name field to a fully qualified input. */
|
|
164
|
+
const fieldNameToReferenceInput = (stepName, fieldName) => fieldName
|
|
165
|
+
? { type: "reference", value: `${stepName}.results.${fieldName}` }
|
|
166
|
+
: undefined;
|
|
167
|
+
/** Actions and Triggers will be scoped to their flow by combining the flow
|
|
168
|
+
* name and the function name. This is to ensure that the keys are unique
|
|
169
|
+
* on the resulting object, which will be turned into a Component. */
|
|
170
|
+
const flowFunctionKey = (flowName, functionName) => {
|
|
171
|
+
const flowKey = flowName
|
|
172
|
+
.replace(/[^0-9a-zA-Z]+/g, " ")
|
|
173
|
+
.trim()
|
|
174
|
+
.split(" ")
|
|
175
|
+
.map((w, i) => i === 0
|
|
176
|
+
? w.toLowerCase()
|
|
177
|
+
: w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
178
|
+
.join("");
|
|
179
|
+
return `${flowKey}_${functionName}`;
|
|
180
|
+
};
|
|
181
|
+
/** Creates the structure necessary to import a Component as part of a
|
|
182
|
+
* Code Native integration. */
|
|
183
|
+
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], }, referenceKey, configVars) => {
|
|
184
|
+
const convertedActions = flows.reduce((result, { name, onExecution }) => {
|
|
185
|
+
const key = flowFunctionKey(name, "onExecution");
|
|
186
|
+
return Object.assign(Object.assign({}, result), { [key]: {
|
|
187
|
+
key,
|
|
188
|
+
display: {
|
|
189
|
+
label: `${name} - onExecution`,
|
|
190
|
+
description: "The function that will be executed by the flow.",
|
|
191
|
+
},
|
|
192
|
+
perform: onExecution,
|
|
193
|
+
inputs: [],
|
|
194
|
+
} });
|
|
195
|
+
}, {});
|
|
196
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete }) => {
|
|
197
|
+
const key = flowFunctionKey(name, "onTrigger");
|
|
198
|
+
return Object.assign(Object.assign({}, result), { [key]: {
|
|
199
|
+
key,
|
|
200
|
+
display: {
|
|
201
|
+
label: `${name} - onTrigger`,
|
|
202
|
+
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
203
|
+
},
|
|
204
|
+
perform: onTrigger,
|
|
205
|
+
onInstanceDeploy,
|
|
206
|
+
hasOnInstanceDeploy: !!onInstanceDeploy,
|
|
207
|
+
onInstanceDelete,
|
|
208
|
+
hasOnInstanceDelete: !!onInstanceDelete,
|
|
209
|
+
inputs: [],
|
|
210
|
+
scheduleSupport: "valid",
|
|
211
|
+
synchronousResponseSupport: "valid",
|
|
212
|
+
} });
|
|
213
|
+
}, {});
|
|
214
|
+
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
215
|
+
if (!(0, types_1.isDataSourceConfigVar)(configVar)) {
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
const dataSource = (0, lodash_1.pick)(configVar, ["perform", "dataSourceType"]);
|
|
219
|
+
return Object.assign(Object.assign({}, result), { [key]: Object.assign(Object.assign({}, dataSource), { key: (0, lodash_1.camelCase)(key), display: {
|
|
220
|
+
label: key,
|
|
221
|
+
description: key,
|
|
222
|
+
}, inputs: [] }) });
|
|
223
|
+
}, {});
|
|
224
|
+
const convertedConnections = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
225
|
+
if (!(0, types_1.isConnectionConfigVar)(configVar)) {
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convert_1.convertInput)(key, value));
|
|
229
|
+
const connection = (0, lodash_1.pick)(configVar, ["oauth2Type", "iconPath"]);
|
|
230
|
+
return [
|
|
231
|
+
...result,
|
|
232
|
+
Object.assign(Object.assign({}, connection), { inputs: convertedInputs, key: (0, lodash_1.camelCase)(key), label: key }),
|
|
233
|
+
];
|
|
234
|
+
}, []);
|
|
235
|
+
return {
|
|
236
|
+
key: referenceKey,
|
|
237
|
+
display: {
|
|
238
|
+
label: referenceKey,
|
|
239
|
+
iconPath,
|
|
240
|
+
description: description || name,
|
|
241
|
+
},
|
|
242
|
+
connections: convertedConnections,
|
|
243
|
+
actions: convertedActions,
|
|
244
|
+
triggers: convertedTriggers,
|
|
245
|
+
dataSources: convertedDataSources,
|
|
246
|
+
};
|
|
247
|
+
};
|
|
@@ -48,12 +48,13 @@ export interface ActionLogger {
|
|
|
48
48
|
warn: ActionLoggerFunction;
|
|
49
49
|
error: ActionLoggerFunction;
|
|
50
50
|
}
|
|
51
|
-
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
51
|
+
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection> = {
|
|
52
52
|
logger: ActionLogger;
|
|
53
53
|
instanceState: Record<string, unknown>;
|
|
54
54
|
crossFlowState: Record<string, unknown>;
|
|
55
55
|
executionState: Record<string, unknown>;
|
|
56
56
|
integrationState: Record<string, unknown>;
|
|
57
|
+
configVars: TConfigVars;
|
|
57
58
|
stepId: string;
|
|
58
59
|
executionId: string;
|
|
59
60
|
webhookUrls: Record<string, string>;
|
|
@@ -65,9 +66,7 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection,
|
|
|
65
66
|
integration: IntegrationAttributes;
|
|
66
67
|
flow: FlowAttributes;
|
|
67
68
|
startedAt: string;
|
|
68
|
-
}
|
|
69
|
-
configVars: TConfigVars;
|
|
70
|
-
} : Record<string, never>);
|
|
69
|
+
};
|
|
71
70
|
declare type TriggerOptionChoice = "invalid" | "valid" | "required";
|
|
72
71
|
export interface TriggerPayload {
|
|
73
72
|
headers: Record<string, string>;
|
|
@@ -112,9 +111,9 @@ interface TriggerBranchingResult extends TriggerBaseResult {
|
|
|
112
111
|
branch: string;
|
|
113
112
|
}
|
|
114
113
|
export declare type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
115
|
-
export declare type TriggerPerformFunction = (context: ActionContext
|
|
114
|
+
export declare type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>;
|
|
116
115
|
export declare type TriggerEventFunctionResult = TriggerEventFunctionReturn | void;
|
|
117
|
-
export declare type TriggerEventFunction = (context: ActionContext
|
|
116
|
+
export declare type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>;
|
|
118
117
|
export interface Trigger {
|
|
119
118
|
key: string;
|
|
120
119
|
display: DisplayDefinition & {
|
|
@@ -137,8 +136,9 @@ export interface Trigger {
|
|
|
137
136
|
examplePayload?: unknown;
|
|
138
137
|
isCommonTrigger?: boolean;
|
|
139
138
|
}
|
|
140
|
-
export interface DataSourceContext {
|
|
139
|
+
export interface DataSourceContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection> {
|
|
141
140
|
logger: ActionLogger;
|
|
141
|
+
configVars: TConfigVars;
|
|
142
142
|
customer: CustomerAttributes;
|
|
143
143
|
instance: InstanceAttributes;
|
|
144
144
|
user: UserAttributes;
|
|
@@ -214,7 +214,7 @@ interface ServerPerformBranchingDataReturn extends ServerPerformDataReturn {
|
|
|
214
214
|
branch: string;
|
|
215
215
|
}
|
|
216
216
|
export declare type ActionPerformReturn = ServerPerformDataStructureReturn | ServerPerformBranchingDataStructureReturn | ServerPerformDataReturn | ServerPerformBranchingDataReturn | undefined;
|
|
217
|
-
export declare type ActionPerformFunction = (context: ActionContext
|
|
217
|
+
export declare type ActionPerformFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<ActionPerformReturn>;
|
|
218
218
|
interface InputFieldChoice {
|
|
219
219
|
label: string;
|
|
220
220
|
value: string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const DefinitionVersion = 7;
|
|
2
|
+
export interface ComponentReference {
|
|
3
|
+
key: string;
|
|
4
|
+
version: number | "LATEST";
|
|
5
|
+
isPublic: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare type Input = {
|
|
8
|
+
name?: string;
|
|
9
|
+
type: "value" | "reference" | "configVar" | "template";
|
|
10
|
+
value: string;
|
|
11
|
+
meta?: Record<string, unknown>;
|
|
12
|
+
} | {
|
|
13
|
+
name?: string;
|
|
14
|
+
type: "complex";
|
|
15
|
+
value: string | Input;
|
|
16
|
+
meta?: Record<string, unknown>;
|
|
17
|
+
};
|
|
18
|
+
export interface ConnectionRequiredConfigVariable {
|
|
19
|
+
key: string;
|
|
20
|
+
stableKey: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
orgOnly?: boolean;
|
|
23
|
+
dataType: "connection";
|
|
24
|
+
connection: {
|
|
25
|
+
component: ComponentReference;
|
|
26
|
+
key: string;
|
|
27
|
+
};
|
|
28
|
+
inputs?: Record<string, Input>;
|
|
29
|
+
meta?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface DefaultRequiredConfigVariable {
|
|
32
|
+
key: string;
|
|
33
|
+
stableKey: string;
|
|
34
|
+
defaultValue?: string;
|
|
35
|
+
dataType: "string" | "date" | "timestamp" | "picklist" | "schedule" | "code" | "boolean" | "number" | "objectSelection" | "objectFieldMap" | "jsonForm";
|
|
36
|
+
pickList?: string[];
|
|
37
|
+
scheduleType?: "none" | "custom" | "minute" | "hour" | "day" | "week";
|
|
38
|
+
timeZone?: string;
|
|
39
|
+
codeLanguage?: "json" | "xml" | "html";
|
|
40
|
+
description?: string;
|
|
41
|
+
orgOnly?: boolean;
|
|
42
|
+
collectionType?: "valuelist" | "keyvaluelist";
|
|
43
|
+
dataSource?: {
|
|
44
|
+
component: ComponentReference;
|
|
45
|
+
key: string;
|
|
46
|
+
};
|
|
47
|
+
inputs?: Record<string, Input>;
|
|
48
|
+
meta?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
export declare type RequiredConfigVariable = DefaultRequiredConfigVariable | ConnectionRequiredConfigVariable;
|
|
51
|
+
export interface ConfigPage {
|
|
52
|
+
name: string;
|
|
53
|
+
tagline?: string;
|
|
54
|
+
userLevelConfigured?: boolean;
|
|
55
|
+
elements: ConfigPageElement[];
|
|
56
|
+
}
|
|
57
|
+
export interface ConfigPageElement {
|
|
58
|
+
type: "configVar" | "htmlElement" | "jsonForm";
|
|
59
|
+
value: string;
|
|
60
|
+
}
|
package/dist/testing.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
|
|
6
6
|
*/
|
|
7
7
|
import { TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn, DataSourceResult, DataSourceContext } from "./serverTypes";
|
|
8
|
-
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection,
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection, ConfigPages } from "./types";
|
|
9
9
|
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown> | undefined) => ConnectionValue;
|
|
10
10
|
/**
|
|
11
11
|
* Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
|
|
@@ -25,7 +25,7 @@ interface InvokeReturn<ReturnData> {
|
|
|
25
25
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
26
26
|
* action result and a mock logger for asserting logging.
|
|
27
27
|
*/
|
|
28
|
-
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
|
|
28
|
+
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>> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
29
29
|
export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
30
30
|
/**
|
|
31
31
|
* Invokes specified TriggerDefinition perform function using supplied params
|
|
@@ -33,13 +33,13 @@ export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
|
33
33
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
34
34
|
* trigger result and a mock logger for asserting logging.
|
|
35
35
|
*/
|
|
36
|
-
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
|
|
36
|
+
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>> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
37
37
|
/**
|
|
38
38
|
* Invokes specified DataSourceDefinition perform function using supplied params.
|
|
39
39
|
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
40
40
|
* casting within test methods. Returns a DataSourceResult.
|
|
41
41
|
*/
|
|
42
|
-
export declare const invokeDataSource: <TInputs extends Inputs, TDataSourceType extends keyof {
|
|
42
|
+
export declare const invokeDataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends keyof {
|
|
43
43
|
string: string;
|
|
44
44
|
date: string;
|
|
45
45
|
timestamp: string;
|
|
@@ -48,38 +48,40 @@ export declare const invokeDataSource: <TInputs extends Inputs, TDataSourceType
|
|
|
48
48
|
value: string;
|
|
49
49
|
};
|
|
50
50
|
code: string;
|
|
51
|
-
credential: unknown;
|
|
52
51
|
boolean: boolean;
|
|
53
52
|
number: number;
|
|
54
|
-
connection: import("./types").Connection;
|
|
55
53
|
objectSelection: import("./types").ObjectSelection;
|
|
56
54
|
objectFieldMap: import("./types").ObjectFieldMap;
|
|
57
55
|
jsonForm: import("./types").JSONForm;
|
|
58
|
-
}>({ perform }: DataSourceDefinition<TInputs, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext
|
|
56
|
+
}>({ perform }: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext<TConfigVars>> | undefined) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
57
|
+
declare type TestConnectionValue = Pick<ConnectionValue, "fields" | "context" | "token">;
|
|
58
|
+
declare type TestConfigVarValues = Record<string, string | TestConnectionValue>;
|
|
59
|
+
declare type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
60
|
+
[K in keyof TConfigVars]: TConfigVars[K] extends ConnectionDefinition ? TestConnectionValue : string;
|
|
61
|
+
};
|
|
59
62
|
/**
|
|
60
63
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
61
64
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
62
65
|
*/
|
|
63
|
-
export declare const invokeFlow: <TConfigVars extends
|
|
66
|
+
export declare const invokeFlow: <TConfigPages extends ConfigPages, TConfigVars extends ConfigVarResultCollection = import("./types/utils").Prettify<{ [Key in keyof (TConfigPages extends ConfigPages ? import("./types/utils").UnionToIntersection<import("./types/utils").ValueOf<TConfigPages>["elements"]> : never)]: import("./types").ElementToRuntimeType<(TConfigPages extends ConfigPages ? import("./types/utils").UnionToIntersection<import("./types/utils").ValueOf<TConfigPages>["elements"]> : never)[Key]>; }>, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow<TConfigPages, import("./types").TriggerPayload>, configVars: TConfigVarValues, context?: Partial<ActionContext<TConfigVars>> | undefined, payload?: TriggerPayload | undefined) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
64
67
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
65
68
|
component: TComponent;
|
|
66
69
|
constructor(component: TComponent);
|
|
67
|
-
private buildContext;
|
|
68
70
|
private buildParams;
|
|
69
71
|
connectionValue({ key }: ConnectionDefinition): ConnectionValue;
|
|
70
72
|
trigger<TConfigVars extends ConfigVarResultCollection>(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerResult>;
|
|
71
73
|
triggerOnInstanceDeploy<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<void | TriggerEventFunctionReturn>;
|
|
72
74
|
triggerOnInstanceDelete<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<void | TriggerEventFunctionReturn>;
|
|
73
75
|
action<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<ActionPerformReturn>;
|
|
74
|
-
dataSource(key: string, params?: Record<string, unknown>, context?: Partial<DataSourceContext
|
|
76
|
+
dataSource<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<DataSourceContext<TConfigVars>>): Promise<DataSourceResult>;
|
|
75
77
|
}
|
|
76
78
|
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
77
79
|
declare const _default: {
|
|
78
80
|
loggerMock: () => ActionLogger;
|
|
79
|
-
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
|
|
80
|
-
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
|
|
81
|
+
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>> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
82
|
+
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>> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs_1> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
81
83
|
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
82
|
-
invokeDataSource: <TInputs_2 extends Inputs, TDataSourceType extends keyof {
|
|
84
|
+
invokeDataSource: <TInputs_2 extends Inputs, TConfigVars_2 extends ConfigVarResultCollection, TDataSourceType extends keyof {
|
|
83
85
|
string: string;
|
|
84
86
|
date: string;
|
|
85
87
|
timestamp: string;
|
|
@@ -88,13 +90,11 @@ declare const _default: {
|
|
|
88
90
|
value: string;
|
|
89
91
|
};
|
|
90
92
|
code: string;
|
|
91
|
-
credential: unknown;
|
|
92
93
|
boolean: boolean;
|
|
93
94
|
number: number;
|
|
94
|
-
connection: import("./types").Connection;
|
|
95
95
|
objectSelection: import("./types").ObjectSelection;
|
|
96
96
|
objectFieldMap: import("./types").ObjectFieldMap;
|
|
97
97
|
jsonForm: import("./types").JSONForm;
|
|
98
|
-
}>({ perform }: DataSourceDefinition<TInputs_2, TDataSourceType>, params: ActionInputParameters<TInputs_2>, context?: Partial<DataSourceContext
|
|
98
|
+
}>({ perform }: DataSourceDefinition<TInputs_2, TConfigVars_2, TDataSourceType>, params: ActionInputParameters<TInputs_2>, context?: Partial<DataSourceContext<TConfigVars_2>> | undefined) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
99
99
|
};
|
|
100
100
|
export default _default;
|
package/dist/testing.js
CHANGED
|
@@ -39,7 +39,7 @@ const loggerMock = () => ({
|
|
|
39
39
|
});
|
|
40
40
|
exports.loggerMock = loggerMock;
|
|
41
41
|
const createActionContext = (context) => {
|
|
42
|
-
return Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, integrationState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
42
|
+
return Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, integrationState: {}, configVars: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
43
43
|
"Flow 1": "https://example.com",
|
|
44
44
|
}, webhookApiKeys: {
|
|
45
45
|
"Flow 1": ["example-123", "example-456"],
|
|
@@ -65,6 +65,21 @@ const createActionContext = (context) => {
|
|
|
65
65
|
name: "Flow 1",
|
|
66
66
|
}, startedAt: new Date().toISOString() }, context);
|
|
67
67
|
};
|
|
68
|
+
const createDataSourceContext = (context) => {
|
|
69
|
+
return Object.assign({ logger: (0, exports.loggerMock)(), configVars: {}, customer: {
|
|
70
|
+
id: "customerId",
|
|
71
|
+
name: "Customer 1",
|
|
72
|
+
externalId: "1234",
|
|
73
|
+
}, instance: {
|
|
74
|
+
id: "instanceId",
|
|
75
|
+
name: "Instance 1",
|
|
76
|
+
}, user: {
|
|
77
|
+
id: "userId",
|
|
78
|
+
email: "example@email.com",
|
|
79
|
+
externalId: "1234",
|
|
80
|
+
name: "Example",
|
|
81
|
+
} }, context);
|
|
82
|
+
};
|
|
68
83
|
/**
|
|
69
84
|
* Invokes specified ActionDefinition perform function using supplied params
|
|
70
85
|
* and optional context. Accepts a generic type matching ActionPerformReturn as a convenience
|
|
@@ -151,41 +166,33 @@ const invokeTrigger = ({ perform, }, context, payload, params) => __awaiter(void
|
|
|
151
166
|
};
|
|
152
167
|
});
|
|
153
168
|
exports.invokeTrigger = invokeTrigger;
|
|
154
|
-
const baseDataSourceContext = {
|
|
155
|
-
logger: (0, exports.loggerMock)(),
|
|
156
|
-
customer: {
|
|
157
|
-
id: "customerId",
|
|
158
|
-
name: "Customer 1",
|
|
159
|
-
externalId: "1234",
|
|
160
|
-
},
|
|
161
|
-
instance: {
|
|
162
|
-
id: "instanceId",
|
|
163
|
-
name: "Instance 1",
|
|
164
|
-
},
|
|
165
|
-
user: {
|
|
166
|
-
id: "userId",
|
|
167
|
-
email: "example@email.com",
|
|
168
|
-
externalId: "1234",
|
|
169
|
-
name: "Example",
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
169
|
/**
|
|
173
170
|
* Invokes specified DataSourceDefinition perform function using supplied params.
|
|
174
171
|
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
175
172
|
* casting within test methods. Returns a DataSourceResult.
|
|
176
173
|
*/
|
|
177
174
|
const invokeDataSource = ({ perform }, params, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
|
-
const realizedContext =
|
|
175
|
+
const realizedContext = createDataSourceContext(context);
|
|
179
176
|
const result = yield perform(realizedContext, params);
|
|
180
177
|
return result;
|
|
181
178
|
});
|
|
182
179
|
exports.invokeDataSource = invokeDataSource;
|
|
180
|
+
const createConfigVars = (values) => {
|
|
181
|
+
return Object.entries(values).reduce((result, [key, value]) => {
|
|
182
|
+
// Connection
|
|
183
|
+
if (typeof value === "object" && "fields" in value) {
|
|
184
|
+
return Object.assign(Object.assign({}, result), { [key]: Object.assign(Object.assign({}, value), { key, configVarKey: "" }) });
|
|
185
|
+
}
|
|
186
|
+
return Object.assign(Object.assign({}, result), { [key]: value });
|
|
187
|
+
}, {});
|
|
188
|
+
};
|
|
183
189
|
/**
|
|
184
190
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
185
191
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
186
192
|
*/
|
|
187
|
-
const invokeFlow = (flow, context, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
188
|
-
const
|
|
193
|
+
const invokeFlow = (flow, configVars, context, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
+
const realizedConfigVars = createConfigVars(configVars);
|
|
195
|
+
const realizedContext = createActionContext(Object.assign(Object.assign({}, context), { configVars: realizedConfigVars }));
|
|
189
196
|
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
|
|
190
197
|
const params = {
|
|
191
198
|
onTrigger: { results: null },
|
|
@@ -205,9 +212,6 @@ class ComponentTestHarness {
|
|
|
205
212
|
constructor(component) {
|
|
206
213
|
this.component = component;
|
|
207
214
|
}
|
|
208
|
-
buildContext(baseContext, context) {
|
|
209
|
-
return Object.assign(Object.assign({}, baseContext), context);
|
|
210
|
-
}
|
|
211
215
|
buildParams(inputs, params) {
|
|
212
216
|
const defaults = inputs.reduce((result, { key, default: defaultValue }) => (Object.assign(Object.assign({}, result), { [key]: `${defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""}` })), {});
|
|
213
217
|
return Object.assign(Object.assign({}, defaults), params);
|
|
@@ -253,7 +257,7 @@ class ComponentTestHarness {
|
|
|
253
257
|
dataSource(key, params, context) {
|
|
254
258
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
259
|
const dataSource = this.component.dataSources[key];
|
|
256
|
-
return dataSource.perform(
|
|
260
|
+
return dataSource.perform(createDataSourceContext(context), this.buildParams(dataSource.inputs, params));
|
|
257
261
|
});
|
|
258
262
|
}
|
|
259
263
|
}
|
|
@@ -7,7 +7,7 @@ export interface ActionDefinition<TInputs extends Inputs = Inputs, TConfigVars e
|
|
|
7
7
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
8
8
|
display: ActionDisplayDefinition;
|
|
9
9
|
/** Function to perform when this Action is invoked. */
|
|
10
|
-
perform: ActionPerformFunction<TInputs, TConfigVars,
|
|
10
|
+
perform: ActionPerformFunction<TInputs, TConfigVars, TAllowsBranching, TReturn>;
|
|
11
11
|
/** InputFields to present in the Prismatic interface for configuration of this Action. */
|
|
12
12
|
inputs: TInputs;
|
|
13
13
|
/** Optional attribute that specifies whether an Action will terminate execution.*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Inputs, ConfigVarResultCollection, ActionPerformReturn, ActionInputParameters, ActionLogger, InstanceAttributes, CustomerAttributes, UserAttributes, IntegrationAttributes, FlowAttributes } from ".";
|
|
2
2
|
/** Definition of the function to perform when an Action is invoked. */
|
|
3
|
-
export declare type ActionPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection,
|
|
3
|
+
export declare type ActionPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean | undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext<TConfigVars>, params: ActionInputParameters<TInputs>) => Promise<TReturn>;
|
|
4
4
|
/** Context provided to perform method containing helpers and contextual data */
|
|
5
|
-
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
5
|
+
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection> = {
|
|
6
6
|
/** Logger for permanent logging; console calls are also captured */
|
|
7
7
|
logger: ActionLogger;
|
|
8
8
|
/** A a flow-specific key/value store that may be used to store small amounts of data that is persisted between Instance executions */
|
|
@@ -13,6 +13,8 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
|
13
13
|
executionState: Record<string, unknown>;
|
|
14
14
|
/** A key/value store that is shared between all flows of an Instance for any version of an Integration that may be used to store small amounts of data that is persisted between Instance executions */
|
|
15
15
|
integrationState: Record<string, unknown>;
|
|
16
|
+
/** Key/value collection of config variables of the integration. */
|
|
17
|
+
configVars: TConfigVars;
|
|
16
18
|
/** A unique id that corresponds to the step on the Integration */
|
|
17
19
|
stepId: string;
|
|
18
20
|
/** A unique id that corresponds to the specific execution of the Integration */
|
|
@@ -35,7 +37,4 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
|
35
37
|
flow: FlowAttributes;
|
|
36
38
|
/** The time in UTC that execution started. */
|
|
37
39
|
startedAt: string;
|
|
38
|
-
}
|
|
39
|
-
/** Key/value collection of config variables of the integration. */
|
|
40
|
-
configVars: TConfigVars;
|
|
41
|
-
} : Record<string, never>);
|
|
40
|
+
};
|
|
@@ -17,7 +17,7 @@ export declare type ComponentDefinition<TPublic extends boolean, TKey extends st
|
|
|
17
17
|
/** Specifies the supported Triggers of this Component. */
|
|
18
18
|
triggers?: Record<string, TriggerDefinition<any, any, boolean, any>>;
|
|
19
19
|
/** Specifies the supported Data Sources of this Component. */
|
|
20
|
-
dataSources?: Record<string, DataSourceDefinition<any, any>>;
|
|
20
|
+
dataSources?: Record<string, DataSourceDefinition<any, any, any>>;
|
|
21
21
|
/** Specifies the supported Connections of this Component. */
|
|
22
22
|
connections?: ConnectionDefinition[];
|
|
23
23
|
/** Hooks */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ActionDisplayDefinition, DataSourcePerformFunction, Inputs, DataSourceType } from ".";
|
|
1
|
+
import { ActionDisplayDefinition, DataSourcePerformFunction, Inputs, DataSourceType, ConfigVarResultCollection } from ".";
|
|
2
2
|
/**
|
|
3
3
|
* DataSourceDefinition is the type of the object that is passed in to `dataSource` function to
|
|
4
4
|
* define a component Data Source.
|
|
5
5
|
*/
|
|
6
|
-
export interface DataSourceDefinition<TInputs extends Inputs, TDataSourceType extends DataSourceType> {
|
|
6
|
+
export interface DataSourceDefinition<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends DataSourceType> {
|
|
7
7
|
/** Defines how the Data Source is displayed in the Prismatic interface. */
|
|
8
8
|
display: ActionDisplayDefinition;
|
|
9
9
|
/** Function to perform when this Data Source is invoked; fetches data from the data source. */
|
|
10
|
-
perform: DataSourcePerformFunction<TInputs, TDataSourceType>;
|
|
10
|
+
perform: DataSourcePerformFunction<TInputs, TConfigVars, TDataSourceType>;
|
|
11
11
|
/** The type of data that this Data Source represents. */
|
|
12
12
|
dataSourceType: TDataSourceType;
|
|
13
13
|
/** InputFields to present in the Prismatic interface for configuration of this Data Source. */
|