@prismatic-io/spectral 8.1.6 → 9.0.0-rc.1
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/bin/component-manifest.js +2 -0
- package/dist/generators/componentManifest/cli.d.ts +2 -0
- package/dist/generators/componentManifest/cli.js +134 -0
- package/dist/generators/componentManifest/createActions.d.ts +13 -0
- package/dist/generators/componentManifest/createActions.js +95 -0
- package/dist/generators/componentManifest/createConnections.d.ts +13 -0
- package/dist/generators/componentManifest/createConnections.js +95 -0
- package/dist/generators/componentManifest/createDataSources.d.ts +13 -0
- package/dist/generators/componentManifest/createDataSources.js +95 -0
- package/dist/generators/componentManifest/createStaticFiles.d.ts +80 -0
- package/dist/generators/componentManifest/createStaticFiles.js +145 -0
- package/dist/generators/componentManifest/createTriggers.d.ts +13 -0
- package/dist/generators/componentManifest/createTriggers.js +95 -0
- package/dist/generators/componentManifest/getImports.d.ts +7 -0
- package/dist/generators/componentManifest/getImports.js +16 -0
- package/dist/generators/componentManifest/getInputs.d.ts +23 -0
- package/dist/generators/componentManifest/getInputs.js +66 -0
- package/dist/generators/componentManifest/helpers.d.ts +5 -0
- package/dist/generators/componentManifest/helpers.js +11 -0
- package/dist/generators/componentManifest/index.d.ts +15 -0
- package/dist/generators/componentManifest/index.js +78 -0
- package/dist/generators/componentManifest/removeComponentManifest.d.ts +6 -0
- package/dist/generators/componentManifest/removeComponentManifest.js +19 -0
- package/dist/generators/componentManifest/templates/README.md.ejs +186 -0
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/actions/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/connections/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/dataSources/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/index.ts.ejs +20 -0
- package/dist/generators/componentManifest/templates/package.json.ejs +23 -0
- package/dist/generators/componentManifest/templates/partials/importBarrel.ejs +9 -0
- package/dist/generators/componentManifest/templates/partials/imports.ejs +1 -0
- package/dist/generators/componentManifest/templates/partials/inputTypes.ejs +10 -0
- package/dist/generators/componentManifest/templates/triggers/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/tsconfig.json.ejs +15 -0
- package/dist/generators/utils/capitalizeFirstLetter.d.ts +1 -0
- package/dist/generators/utils/capitalizeFirstLetter.js +5 -0
- package/dist/generators/utils/createDependencyImports.d.ts +5 -0
- package/dist/generators/utils/createDependencyImports.js +9 -0
- package/dist/generators/utils/createFlagHelpText.d.ts +12 -0
- package/dist/generators/utils/createFlagHelpText.js +19 -0
- package/dist/generators/utils/createTemplate.d.ts +9 -0
- package/dist/generators/utils/createTemplate.js +59 -0
- package/dist/generators/utils/generatePackageJsonVersion.d.ts +1 -0
- package/dist/generators/utils/generatePackageJsonVersion.js +14 -0
- package/dist/generators/utils/getComponentSignatureWithPrism.d.ts +1 -0
- package/dist/generators/utils/getComponentSignatureWithPrism.js +39 -0
- package/dist/generators/utils/getFlagBooleanValue.d.ts +11 -0
- package/dist/generators/utils/getFlagBooleanValue.js +17 -0
- package/dist/generators/utils/getFlagStringValue.d.ts +11 -0
- package/dist/generators/utils/getFlagStringValue.js +25 -0
- package/dist/generators/utils/truncatePathByFolder.d.ts +1 -0
- package/dist/generators/utils/truncatePathByFolder.js +5 -0
- package/dist/index.d.ts +14 -15
- package/dist/index.js +9 -9
- package/dist/serverTypes/convertIntegration.d.ts +2 -2
- package/dist/serverTypes/convertIntegration.js +97 -43
- package/dist/serverTypes/index.d.ts +3 -2
- package/dist/serverTypes/integration.d.ts +12 -4
- package/dist/testing.d.ts +7 -7
- package/dist/testing.js +1 -1
- package/dist/types/ActionDefinition.d.ts +2 -1
- package/dist/types/ActionPerformFunction.d.ts +5 -3
- package/dist/types/ComponentManifest.d.ts +13 -0
- package/dist/types/ComponentManifest.js +2 -0
- package/dist/types/DataSourceResult.d.ts +1 -0
- package/dist/types/IntegrationDefinition.d.ts +148 -77
- package/dist/types/IntegrationDefinition.js +9 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.js +17 -10
- package/package.json +12 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* authors create inputs, actions, and components that can
|
|
4
4
|
* be processed by the Prismatic API.
|
|
5
5
|
*/
|
|
6
|
-
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar,
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ScheduleConfigVar, ComponentManifest } from "./types";
|
|
7
7
|
import { convertComponent } from "./serverTypes/convert";
|
|
8
8
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
9
9
|
/**
|
|
@@ -14,28 +14,21 @@ import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
|
14
14
|
* @param definition An IntegrationDefinition type object.
|
|
15
15
|
* @returns This function returns an integration object that has the shape the Prismatic API expects.
|
|
16
16
|
*/
|
|
17
|
-
export declare const integration: <T extends IntegrationDefinition
|
|
17
|
+
export declare const integration: <T extends IntegrationDefinition = IntegrationDefinition>(definition: T) => ReturnType<typeof convertIntegration>;
|
|
18
18
|
/**
|
|
19
19
|
* For information on writing Code Native Integrations, see
|
|
20
20
|
* https://prismatic.io/docs/code-native-integrations/#adding-flows.
|
|
21
21
|
* @param definition A Flow type object.
|
|
22
22
|
* @returns This function returns a flow object that has the shape the Prismatic API expects.
|
|
23
23
|
*/
|
|
24
|
-
export declare const flow: <
|
|
24
|
+
export declare const flow: <TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TTriggerPayload> = Flow<TTriggerPayload>>(definition: T) => T;
|
|
25
25
|
/**
|
|
26
26
|
* For information on writing Code Native Integrations, see
|
|
27
27
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-pages.
|
|
28
28
|
* @param definition A Config Page type object.
|
|
29
29
|
* @returns This function returns a config page object that has the shape the Prismatic API expects.
|
|
30
30
|
*/
|
|
31
|
-
export declare const configPage: <T extends ConfigPage
|
|
32
|
-
/**
|
|
33
|
-
* @returns Helper utility to create component references.
|
|
34
|
-
*/
|
|
35
|
-
export declare const reference: <TComponents extends ComponentSelector<any>>() => {
|
|
36
|
-
connection: <T extends ConnectionConfigVar<TComponents>>(definition: T) => T;
|
|
37
|
-
dataSource: <T_1 extends DataSourceConfigVar<TComponents>>(definition: T_1) => T_1;
|
|
38
|
-
};
|
|
31
|
+
export declare const configPage: <T extends ConfigPage = ConfigPage>(definition: T) => T;
|
|
39
32
|
/**
|
|
40
33
|
* For information on writing Code Native Integrations, see
|
|
41
34
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
@@ -49,14 +42,19 @@ export declare const configVar: <T extends StandardConfigVar | ScheduleConfigVar
|
|
|
49
42
|
* @param definition A Data Source Config Var type object.
|
|
50
43
|
* @returns This function returns a data source config var object that has the shape the Prismatic API expects.
|
|
51
44
|
*/
|
|
52
|
-
export declare const dataSourceConfigVar: <
|
|
45
|
+
export declare const dataSourceConfigVar: <TDataSourceConfigVar extends DataSourceConfigVar>(definition: TDataSourceConfigVar) => TDataSourceConfigVar;
|
|
53
46
|
/**
|
|
54
47
|
* For information on writing Code Native Integrations, see
|
|
55
48
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
56
49
|
* @param definition A Connection Config Var type object.
|
|
57
50
|
* @returns This function returns a connection config var object that has the shape the Prismatic API expects.
|
|
58
51
|
*/
|
|
59
|
-
export declare const connectionConfigVar: <T extends ConnectionConfigVar
|
|
52
|
+
export declare const connectionConfigVar: <T extends ConnectionConfigVar = ConnectionConfigVar>(definition: T) => T;
|
|
53
|
+
/**
|
|
54
|
+
* @param definition A Component Manifest type object.
|
|
55
|
+
* @returns This function returns a component manifest object that has the shape the Prismatic API expects.
|
|
56
|
+
*/
|
|
57
|
+
export declare const componentManifest: <T extends ComponentManifest>(definition: T) => T;
|
|
60
58
|
/**
|
|
61
59
|
* This function creates a component object that can be
|
|
62
60
|
* imported into the Prismatic API. For information on using
|
|
@@ -75,7 +73,7 @@ export declare const component: <TPublic extends boolean, TKey extends string>(d
|
|
|
75
73
|
* @param definition An ActionDefinition type object that includes UI display information, a function to perform when the action is invoked, and a an object containing inputs for the perform function.
|
|
76
74
|
* @returns This function validates the shape of the `definition` object provided, and returns the same action object.
|
|
77
75
|
*/
|
|
78
|
-
export declare const action: <TInputs extends Inputs,
|
|
76
|
+
export declare const action: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>>(definition: ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>) => ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>;
|
|
79
77
|
/**
|
|
80
78
|
* This function creates a trigger object that can be referenced
|
|
81
79
|
* by a custom component. It helps ensure that the shape of the
|
|
@@ -85,7 +83,7 @@ export declare const action: <TInputs extends Inputs, TConfigVar extends ConfigV
|
|
|
85
83
|
* @param definition A TriggerDefinition type object that includes UI display information, a function to perform when the trigger is invoked, and a an object containing inputs for the perform function.
|
|
86
84
|
* @returns This function validates the shape of the `definition` object provided, and returns the same trigger object.
|
|
87
85
|
*/
|
|
88
|
-
export declare const trigger: <TInputs extends Inputs,
|
|
86
|
+
export declare const trigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>>(definition: TriggerDefinition<TInputs, TConfigVars, TAllowsBranching, TResult>) => TriggerDefinition<TInputs, TConfigVars, TAllowsBranching, TResult>;
|
|
89
87
|
/**
|
|
90
88
|
* This function creates a data source object that can be referenced
|
|
91
89
|
* by a custom component. It helps ensure that the shape of the
|
|
@@ -139,6 +137,7 @@ export declare const onPremConnection: <T extends OnPremConnectionDefinition>(de
|
|
|
139
137
|
* @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
|
|
140
138
|
*/
|
|
141
139
|
export declare const oauth2Connection: <T extends OAuth2ConnectionDefinition>(definition: T) => T;
|
|
140
|
+
export declare const componentManifests: <T extends Record<string, ComponentManifest>>(definition: T) => T;
|
|
142
141
|
export { default as util } from "./util";
|
|
143
142
|
export * from "./types";
|
|
144
143
|
export { default as testing } from "./testing";
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.testing = exports.util = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.
|
|
25
|
+
exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
26
26
|
const convert_1 = require("./serverTypes/convert");
|
|
27
27
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
28
28
|
/**
|
|
@@ -58,14 +58,6 @@ exports.flow = flow;
|
|
|
58
58
|
*/
|
|
59
59
|
const configPage = (definition) => definition;
|
|
60
60
|
exports.configPage = configPage;
|
|
61
|
-
/**
|
|
62
|
-
* @returns Helper utility to create component references.
|
|
63
|
-
*/
|
|
64
|
-
const reference = () => ({
|
|
65
|
-
connection: (definition) => definition,
|
|
66
|
-
dataSource: (definition) => definition,
|
|
67
|
-
});
|
|
68
|
-
exports.reference = reference;
|
|
69
61
|
/**
|
|
70
62
|
* For information on writing Code Native Integrations, see
|
|
71
63
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
@@ -90,6 +82,12 @@ exports.dataSourceConfigVar = dataSourceConfigVar;
|
|
|
90
82
|
*/
|
|
91
83
|
const connectionConfigVar = (definition) => definition;
|
|
92
84
|
exports.connectionConfigVar = connectionConfigVar;
|
|
85
|
+
/**
|
|
86
|
+
* @param definition A Component Manifest type object.
|
|
87
|
+
* @returns This function returns a component manifest object that has the shape the Prismatic API expects.
|
|
88
|
+
*/
|
|
89
|
+
const componentManifest = (definition) => definition;
|
|
90
|
+
exports.componentManifest = componentManifest;
|
|
93
91
|
/**
|
|
94
92
|
* This function creates a component object that can be
|
|
95
93
|
* imported into the Prismatic API. For information on using
|
|
@@ -166,6 +164,8 @@ exports.onPremConnection = onPremConnection;
|
|
|
166
164
|
*/
|
|
167
165
|
const oauth2Connection = (definition) => definition;
|
|
168
166
|
exports.oauth2Connection = oauth2Connection;
|
|
167
|
+
const componentManifests = (definition) => definition;
|
|
168
|
+
exports.componentManifests = componentManifests;
|
|
169
169
|
var util_1 = require("./util");
|
|
170
170
|
Object.defineProperty(exports, "util", { enumerable: true, get: function () { return __importDefault(util_1).default; } });
|
|
171
171
|
__exportStar(require("./types"), exports);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IntegrationDefinition
|
|
1
|
+
import { IntegrationDefinition } from "../types";
|
|
2
2
|
import { Component as ServerComponent } from ".";
|
|
3
|
-
export declare const convertIntegration: (definition: IntegrationDefinition
|
|
3
|
+
export declare const convertIntegration: (definition: IntegrationDefinition) => ServerComponent;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
17
|
exports.convertIntegration = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
8
18
|
const yaml_1 = __importDefault(require("yaml"));
|
|
9
19
|
const uuid_1 = require("uuid");
|
|
10
20
|
const lodash_1 = require("lodash");
|
|
@@ -34,7 +44,7 @@ const convertConfigPages = (pages) => {
|
|
|
34
44
|
})),
|
|
35
45
|
}));
|
|
36
46
|
};
|
|
37
|
-
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, }, referenceKey, configVars) => {
|
|
47
|
+
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, componentRegistry = {}, }, referenceKey, configVars) => {
|
|
38
48
|
// Find the preprocess flow config on the flow, if one exists.
|
|
39
49
|
const preprocessFlows = flows.filter((flow) => flow.preprocessFlowConfig);
|
|
40
50
|
// Do some validation of preprocess flow configs.
|
|
@@ -68,32 +78,38 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
68
78
|
documentation,
|
|
69
79
|
version,
|
|
70
80
|
labels,
|
|
71
|
-
requiredConfigVars: Object.entries(configVars || {}).map(([key, configVar]) => convertConfigVar(key, configVar, referenceKey)),
|
|
81
|
+
requiredConfigVars: Object.entries(configVars || {}).map(([key, configVar]) => convertConfigVar(key, configVar, referenceKey, componentRegistry)),
|
|
72
82
|
endpointType,
|
|
73
83
|
preprocessFlowName: hasPreprocessFlow ? preprocessFlows[0].name : undefined,
|
|
74
84
|
externalCustomerIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerIdField),
|
|
75
85
|
externalCustomerUserIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerUserIdField),
|
|
76
86
|
flowNameField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.flowNameField),
|
|
77
|
-
flows: flows.map((flow) => convertFlow(flow, referenceKey)),
|
|
87
|
+
flows: flows.map((flow) => convertFlow(flow, componentRegistry, referenceKey)),
|
|
78
88
|
configPages: convertConfigPages(configPages !== null && configPages !== void 0 ? configPages : {}),
|
|
79
89
|
};
|
|
80
90
|
return yaml_1.default.stringify(result);
|
|
81
91
|
};
|
|
82
|
-
const convertComponentReference = (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
const inputs = Object.entries(values !== null && values !== void 0 ? values : {}).reduce((result, [key, value]) => {
|
|
92
|
+
const convertComponentReference = (componentReference, componentRegistry) => {
|
|
93
|
+
var _a, _b, _c;
|
|
94
|
+
const ref = {
|
|
95
|
+
component: {
|
|
96
|
+
key: componentReference.component,
|
|
97
|
+
signature: (_b = (_a = componentRegistry[componentReference.component]) === null || _a === void 0 ? void 0 : _a.signature) !== null && _b !== void 0 ? _b : "",
|
|
98
|
+
isPublic: componentReference.isPublic,
|
|
99
|
+
},
|
|
100
|
+
key: componentReference.key,
|
|
101
|
+
};
|
|
102
|
+
const inputs = Object.entries((_c = componentReference.values) !== null && _c !== void 0 ? _c : {}).reduce((result, [key, value]) => {
|
|
95
103
|
if ("value" in value) {
|
|
96
|
-
|
|
104
|
+
const type = value.value instanceof Object ? "complex" : "value";
|
|
105
|
+
const valueExpr = value.value instanceof Object && !Array.isArray(value.value)
|
|
106
|
+
? Object.entries(value.value).map(([k, v]) => ({
|
|
107
|
+
name: { type: "value", value: k },
|
|
108
|
+
type: "value",
|
|
109
|
+
value: v,
|
|
110
|
+
}))
|
|
111
|
+
: value.value;
|
|
112
|
+
return Object.assign(Object.assign({}, result), { [key]: { type: type, value: valueExpr } });
|
|
97
113
|
}
|
|
98
114
|
if ("configVar" in value) {
|
|
99
115
|
return Object.assign(Object.assign({}, result), { [key]: { type: "configVar", value: value.configVar } });
|
|
@@ -101,12 +117,28 @@ const convertComponentReference = ({ key, component: componentRef, values, }) =>
|
|
|
101
117
|
return result;
|
|
102
118
|
}, {});
|
|
103
119
|
return {
|
|
104
|
-
ref
|
|
120
|
+
ref,
|
|
105
121
|
inputs,
|
|
106
122
|
};
|
|
107
123
|
};
|
|
124
|
+
const convertComponentRegistry = (componentRegistry) => Object.values(componentRegistry).map(({ key, public: isPublic, signature }) => ({
|
|
125
|
+
key,
|
|
126
|
+
signature: signature !== null && signature !== void 0 ? signature : "",
|
|
127
|
+
isPublic,
|
|
128
|
+
}));
|
|
129
|
+
/**
|
|
130
|
+
* Create a reference to the private component built as part of this CNI.
|
|
131
|
+
*
|
|
132
|
+
* References to this component always use `version: "LATEST", isPublic: false`
|
|
133
|
+
* because they automatically publish alongside the corresponding CNI yml.
|
|
134
|
+
* */
|
|
135
|
+
const codeNativeIntegrationComponentReference = (referenceKey) => ({
|
|
136
|
+
key: referenceKey,
|
|
137
|
+
version: "LATEST",
|
|
138
|
+
isPublic: false,
|
|
139
|
+
});
|
|
108
140
|
/** Converts a Flow into the structure necessary for YAML generation. */
|
|
109
|
-
const convertFlow = (flow, referenceKey) => {
|
|
141
|
+
const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
110
142
|
var _a;
|
|
111
143
|
const result = Object.assign({}, flow);
|
|
112
144
|
delete result.onTrigger;
|
|
@@ -126,15 +158,11 @@ const convertFlow = (flow, referenceKey) => {
|
|
|
126
158
|
if (typeof flow.onTrigger === "function") {
|
|
127
159
|
triggerStep.action = {
|
|
128
160
|
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
129
|
-
component:
|
|
130
|
-
key: referenceKey,
|
|
131
|
-
version: "LATEST",
|
|
132
|
-
isPublic: false,
|
|
133
|
-
},
|
|
161
|
+
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
134
162
|
};
|
|
135
163
|
}
|
|
136
164
|
else if ((0, types_1.isComponentReference)(flow.onTrigger)) {
|
|
137
|
-
const { ref, inputs } = convertComponentReference(flow.onTrigger);
|
|
165
|
+
const { ref, inputs } = convertComponentReference(flow.onTrigger, componentRegistry);
|
|
138
166
|
triggerStep.action = ref;
|
|
139
167
|
triggerStep.inputs = inputs;
|
|
140
168
|
}
|
|
@@ -143,7 +171,14 @@ const convertFlow = (flow, referenceKey) => {
|
|
|
143
171
|
const key = hasSchedule ? "schedule" : "webhook";
|
|
144
172
|
triggerStep.action = {
|
|
145
173
|
key,
|
|
146
|
-
component: {
|
|
174
|
+
component: {
|
|
175
|
+
key: `${key}-triggers`,
|
|
176
|
+
/**
|
|
177
|
+
* TODO: Add support for specific versions of platform triggers
|
|
178
|
+
*/
|
|
179
|
+
version: "LATEST",
|
|
180
|
+
isPublic: true,
|
|
181
|
+
},
|
|
147
182
|
};
|
|
148
183
|
}
|
|
149
184
|
if ("schedule" in flow && typeof flow.schedule === "object") {
|
|
@@ -161,7 +196,7 @@ const convertFlow = (flow, referenceKey) => {
|
|
|
161
196
|
const actionStep = {
|
|
162
197
|
action: {
|
|
163
198
|
key: flowFunctionKey(flow.name, "onExecution"),
|
|
164
|
-
component:
|
|
199
|
+
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
165
200
|
},
|
|
166
201
|
name: "On Execution",
|
|
167
202
|
stableKey: `${flow.stableKey}-onExecution`,
|
|
@@ -169,32 +204,32 @@ const convertFlow = (flow, referenceKey) => {
|
|
|
169
204
|
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined,
|
|
170
205
|
};
|
|
171
206
|
result.steps = [triggerStep, actionStep];
|
|
207
|
+
result.supplementalComponents = convertComponentRegistry(componentRegistry);
|
|
172
208
|
return result;
|
|
173
209
|
};
|
|
174
210
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
175
|
-
const convertConfigVar = (key, configVar, referenceKey) => {
|
|
211
|
+
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
176
212
|
const meta = (0, lodash_1.pick)(configVar, [
|
|
177
213
|
"visibleToCustomerDeployer",
|
|
178
214
|
"visibleToOrgDeployer",
|
|
179
215
|
]);
|
|
180
216
|
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
181
217
|
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: {
|
|
182
|
-
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
183
218
|
key: (0, lodash_1.camelCase)(key),
|
|
219
|
+
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
184
220
|
}, inputs: Object.entries(configVar.inputs).reduce((result, [key, input]) => {
|
|
185
221
|
if (input.shown === false) {
|
|
186
222
|
return result;
|
|
187
223
|
}
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return Object.assign(Object.assign({}, result), { [key]: { type: "value", value } });
|
|
224
|
+
const defaultValue = input.collection ? [] : "";
|
|
225
|
+
return Object.assign(Object.assign({}, result), { [key]: {
|
|
226
|
+
type: input.collection ? "complex" : "value",
|
|
227
|
+
value: input.default || defaultValue,
|
|
228
|
+
} });
|
|
194
229
|
}, {}), meta });
|
|
195
230
|
}
|
|
196
231
|
if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
|
|
197
|
-
const { ref, inputs } = convertComponentReference(configVar.connection);
|
|
232
|
+
const { ref, inputs } = convertComponentReference(configVar.connection, componentRegistry);
|
|
198
233
|
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: Object.assign(Object.assign({}, ref), { template: configVar.connection.template }), inputs });
|
|
199
234
|
}
|
|
200
235
|
const result = (0, lodash_1.assign)({ meta, key }, (0, lodash_1.pick)(configVar, [
|
|
@@ -215,11 +250,11 @@ const convertConfigVar = (key, configVar, referenceKey) => {
|
|
|
215
250
|
result.dataType = configVar.dataSourceType;
|
|
216
251
|
result.dataSource = {
|
|
217
252
|
key: (0, lodash_1.camelCase)(key),
|
|
218
|
-
component:
|
|
253
|
+
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
219
254
|
};
|
|
220
255
|
}
|
|
221
256
|
if ((0, types_1.isDataSourceReferenceConfigVar)(configVar)) {
|
|
222
|
-
const { ref, inputs } = convertComponentReference(configVar.dataSource);
|
|
257
|
+
const { ref, inputs } = convertComponentReference(configVar.dataSource, componentRegistry);
|
|
223
258
|
result.dataType = configVar.dataSourceType;
|
|
224
259
|
result.dataSource = ref;
|
|
225
260
|
result.inputs = inputs;
|
|
@@ -244,9 +279,28 @@ const flowFunctionKey = (flowName, functionName) => {
|
|
|
244
279
|
.join("");
|
|
245
280
|
return `${flowKey}_${functionName}`;
|
|
246
281
|
};
|
|
282
|
+
const convertOnExecution = (onExecution, componentRegistry) => (context, params) => {
|
|
283
|
+
// @ts-expect-error _components isn't part of the public API
|
|
284
|
+
const { _components } = context, remainingContext = __rest(context, ["_components"]);
|
|
285
|
+
const invoke = _components
|
|
286
|
+
.invoke;
|
|
287
|
+
const componentMethods = Object.entries(componentRegistry).reduce((acc, [componentKey, { actions, public: isPublic, signature }]) => {
|
|
288
|
+
return Object.assign(Object.assign({}, acc), { [componentKey]: Object.keys(actions).reduce((acc, actionKey) => (Object.assign(Object.assign({}, acc), { [actionKey]: (values) => {
|
|
289
|
+
return invoke({
|
|
290
|
+
component: {
|
|
291
|
+
key: componentKey,
|
|
292
|
+
signature: signature !== null && signature !== void 0 ? signature : "",
|
|
293
|
+
isPublic,
|
|
294
|
+
},
|
|
295
|
+
key: actionKey,
|
|
296
|
+
}, context, values);
|
|
297
|
+
} })), {}) });
|
|
298
|
+
}, {});
|
|
299
|
+
return onExecution(Object.assign(Object.assign({}, remainingContext), { components: componentMethods }), params);
|
|
300
|
+
};
|
|
247
301
|
/** Creates the structure necessary to import a Component as part of a
|
|
248
302
|
* Code Native integration. */
|
|
249
|
-
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], }, referenceKey, configVars) => {
|
|
303
|
+
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], componentRegistry = {}, }, referenceKey, configVars) => {
|
|
250
304
|
const convertedActions = flows.reduce((result, { name, onExecution }) => {
|
|
251
305
|
const key = flowFunctionKey(name, "onExecution");
|
|
252
306
|
return Object.assign(Object.assign({}, result), { [key]: {
|
|
@@ -255,7 +309,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
255
309
|
label: `${name} - onExecution`,
|
|
256
310
|
description: "The function that will be executed by the flow.",
|
|
257
311
|
},
|
|
258
|
-
perform: onExecution,
|
|
312
|
+
perform: convertOnExecution(onExecution, componentRegistry),
|
|
259
313
|
inputs: [],
|
|
260
314
|
} });
|
|
261
315
|
}, {});
|
|
@@ -271,9 +325,9 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
271
325
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
272
326
|
},
|
|
273
327
|
perform: onTrigger,
|
|
274
|
-
onInstanceDeploy,
|
|
328
|
+
onInstanceDeploy: onInstanceDeploy,
|
|
275
329
|
hasOnInstanceDeploy: !!onInstanceDeploy,
|
|
276
|
-
onInstanceDelete,
|
|
330
|
+
onInstanceDelete: onInstanceDeploy,
|
|
277
331
|
hasOnInstanceDelete: !!onInstanceDelete,
|
|
278
332
|
inputs: [],
|
|
279
333
|
scheduleSupport: "valid",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { InstanceAttributes, CustomerAttributes, DataSourceType, DataSourceResultType, UserAttributes, TriggerEventFunctionReturn, IntegrationAttributes, FlowAttributes, ConfigVarResultCollection } from "../types";
|
|
2
|
+
import { InstanceAttributes, CustomerAttributes, DataSourceType, DataSourceResultType, UserAttributes, TriggerEventFunctionReturn, IntegrationAttributes, FlowAttributes, ConfigVarResultCollection, ComponentManifest } from "../types";
|
|
3
3
|
interface DisplayDefinition {
|
|
4
4
|
label: string;
|
|
5
5
|
description: string;
|
|
@@ -48,13 +48,14 @@ export interface ActionLogger {
|
|
|
48
48
|
warn: ActionLoggerFunction;
|
|
49
49
|
error: ActionLoggerFunction;
|
|
50
50
|
}
|
|
51
|
-
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection> = {
|
|
51
|
+
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]> = Record<string, ComponentManifest["actions"]>> = {
|
|
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
57
|
configVars: TConfigVars;
|
|
58
|
+
components: TComponentActions;
|
|
58
59
|
stepId: string;
|
|
59
60
|
executionId: string;
|
|
60
61
|
webhookUrls: Record<string, string>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const DefinitionVersion = 7;
|
|
2
|
-
export
|
|
2
|
+
export declare type ComponentReference = {
|
|
3
3
|
component: {
|
|
4
4
|
key: string;
|
|
5
5
|
version: number | "LATEST";
|
|
@@ -7,14 +7,22 @@ export interface ComponentReference {
|
|
|
7
7
|
};
|
|
8
8
|
key: string;
|
|
9
9
|
template?: string;
|
|
10
|
-
}
|
|
10
|
+
} | {
|
|
11
|
+
component: {
|
|
12
|
+
key: string;
|
|
13
|
+
signature: string;
|
|
14
|
+
isPublic: boolean;
|
|
15
|
+
};
|
|
16
|
+
key: string;
|
|
17
|
+
template?: string;
|
|
18
|
+
};
|
|
11
19
|
export declare type Input = {
|
|
12
|
-
name?: string;
|
|
20
|
+
name?: string | Input;
|
|
13
21
|
type: "value" | "reference" | "configVar" | "template";
|
|
14
22
|
value: string;
|
|
15
23
|
meta?: Record<string, unknown>;
|
|
16
24
|
} | {
|
|
17
|
-
name?: string;
|
|
25
|
+
name?: string | Input;
|
|
18
26
|
type: "complex";
|
|
19
27
|
value: string | Input;
|
|
20
28
|
meta?: Record<string, unknown>;
|
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 } 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
|
export declare const defaultConnectionValueEnvironmentVariable = "PRISMATIC_CONNECTION_VALUE";
|
|
11
11
|
export declare const connectionValue: (envVarKey?: string) => ConnectionValue;
|
|
@@ -27,7 +27,7 @@ interface InvokeReturn<ReturnData> {
|
|
|
27
27
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
28
28
|
* action result and a mock logger for asserting logging.
|
|
29
29
|
*/
|
|
30
|
-
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
|
|
30
|
+
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, Record<string, Record<string, import("./types").ComponentManifestAction>>>> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
31
31
|
export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
32
32
|
/**
|
|
33
33
|
* Invokes specified TriggerDefinition perform function using supplied params
|
|
@@ -35,7 +35,7 @@ export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
|
35
35
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
36
36
|
* trigger result and a mock logger for asserting logging.
|
|
37
37
|
*/
|
|
38
|
-
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
|
|
38
|
+
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, Record<string, Record<string, import("./types").ComponentManifestAction>>>> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
39
39
|
/**
|
|
40
40
|
* Invokes specified DataSourceDefinition perform function using supplied params.
|
|
41
41
|
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
@@ -65,9 +65,9 @@ declare type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
|
65
65
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
66
66
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
67
67
|
*/
|
|
68
|
-
export declare const invokeFlow: <
|
|
68
|
+
export declare const invokeFlow: <TConfigVars extends import("./types/utils").Prettify<{} & {}> = import("./types/utils").Prettify<{} & {}>, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow, { configVars, context, payload, }?: {
|
|
69
69
|
configVars?: TConfigVarValues | undefined;
|
|
70
|
-
context?: Partial<ActionContext<TConfigVars
|
|
70
|
+
context?: Partial<ActionContext<TConfigVars, Record<string, Record<string, import("./types").ComponentManifestAction>>>> | undefined;
|
|
71
71
|
payload?: Partial<TriggerPayload> | undefined;
|
|
72
72
|
}) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
73
73
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
@@ -84,8 +84,8 @@ export declare class ComponentTestHarness<TComponent extends Component> {
|
|
|
84
84
|
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
85
85
|
declare const _default: {
|
|
86
86
|
loggerMock: () => ActionLogger;
|
|
87
|
-
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
|
|
88
|
-
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
|
|
87
|
+
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, Record<string, Record<string, import("./types").ComponentManifestAction>>>> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
88
|
+
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, Record<string, Record<string, import("./types").ComponentManifestAction>>>> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs_1> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
89
89
|
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
90
90
|
invokeDataSource: <TInputs_2 extends Inputs, TConfigVars_2 extends ConfigVarResultCollection, TDataSourceType extends keyof {
|
|
91
91
|
string: string;
|
package/dist/testing.js
CHANGED
|
@@ -49,7 +49,7 @@ const loggerMock = () => ({
|
|
|
49
49
|
});
|
|
50
50
|
exports.loggerMock = loggerMock;
|
|
51
51
|
const createActionContext = (context) => {
|
|
52
|
-
return Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, integrationState: {}, configVars: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
52
|
+
return Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, integrationState: {}, configVars: {}, components: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
53
53
|
"Flow 1": "https://example.com",
|
|
54
54
|
}, webhookApiKeys: {
|
|
55
55
|
"Flow 1": ["example-123", "example-456"],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ActionDisplayDefinition, ActionPerformFunction, ActionPerformReturn, ConfigVarResultCollection, Inputs } from ".";
|
|
2
|
+
import { ComponentManifestAction } from "./ComponentManifest";
|
|
2
3
|
/**
|
|
3
4
|
* ActionDefinition is the type of the object that is passed in to `action` function to
|
|
4
5
|
* define a component action.
|
|
@@ -7,7 +8,7 @@ export interface ActionDefinition<TInputs extends Inputs = Inputs, TConfigVars e
|
|
|
7
8
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
8
9
|
display: ActionDisplayDefinition;
|
|
9
10
|
/** Function to perform when this Action is invoked. */
|
|
10
|
-
perform: ActionPerformFunction<TInputs, TConfigVars, TAllowsBranching, TReturn>;
|
|
11
|
+
perform: ActionPerformFunction<TInputs, TConfigVars, Record<string, Record<string, ComponentManifestAction>>, TAllowsBranching, TReturn>;
|
|
11
12
|
/** InputFields to present in the Prismatic interface for configuration of this Action. */
|
|
12
13
|
inputs: TInputs;
|
|
13
14
|
/** Optional attribute that specifies whether an Action will terminate execution.*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Inputs, ConfigVarResultCollection, ActionPerformReturn, ActionInputParameters, ActionLogger, InstanceAttributes, CustomerAttributes, UserAttributes, IntegrationAttributes, FlowAttributes } from ".";
|
|
1
|
+
import { Inputs, ConfigVarResultCollection, ActionPerformReturn, ActionInputParameters, ActionLogger, InstanceAttributes, CustomerAttributes, UserAttributes, IntegrationAttributes, FlowAttributes, ComponentManifest } 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, TAllowsBranching extends boolean | undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext<TConfigVars>, params: ActionInputParameters<TInputs>) => Promise<TReturn>;
|
|
3
|
+
export declare type ActionPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]>, TAllowsBranching extends boolean | undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext<TConfigVars, TComponentActions>, 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 = ConfigVarResultCollection> = {
|
|
5
|
+
export declare type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]> = Record<string, ComponentManifest["actions"]>> = {
|
|
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 */
|
|
@@ -15,6 +15,8 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
|
15
15
|
integrationState: Record<string, unknown>;
|
|
16
16
|
/** Key/value collection of config variables of the integration. */
|
|
17
17
|
configVars: TConfigVars;
|
|
18
|
+
/** Available component actions registered in the `componentRegistry`. */
|
|
19
|
+
components: TComponentActions;
|
|
18
20
|
/** A unique id that corresponds to the step on the Integration */
|
|
19
21
|
stepId: string;
|
|
20
22
|
/** A unique id that corresponds to the specific execution of the Integration */
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ComponentManifest {
|
|
2
|
+
key: string;
|
|
3
|
+
public: boolean;
|
|
4
|
+
signature: string | null;
|
|
5
|
+
actions: Record<string, ComponentManifestAction>;
|
|
6
|
+
triggers: Record<string, ComponentManifestTrigger>;
|
|
7
|
+
dataSources: Record<string, ComponentManifestDataSource>;
|
|
8
|
+
connections: Record<string, ComponentManifestConnection>;
|
|
9
|
+
}
|
|
10
|
+
export declare type ComponentManifestAction = (values: any) => Promise<unknown>;
|
|
11
|
+
export declare type ComponentManifestTrigger = (values: any) => Promise<unknown>;
|
|
12
|
+
export declare type ComponentManifestDataSource = (values: any) => Promise<unknown>;
|
|
13
|
+
export declare type ComponentManifestConnection = (values: any) => Promise<unknown>;
|
|
@@ -16,6 +16,7 @@ declare type DataSourceTypeMap = {
|
|
|
16
16
|
jsonForm: JSONForm;
|
|
17
17
|
};
|
|
18
18
|
export declare type DataSourceType = keyof DataSourceTypeMap;
|
|
19
|
+
export declare type CollectionDataSourceType = Exclude<DataSourceType, "objectSelection" | "objectFieldMap" | "jsonForm">;
|
|
19
20
|
export declare type DataSourceResultType = DataSourceTypeMap[DataSourceType];
|
|
20
21
|
/** Represents the result of a Data Source action. */
|
|
21
22
|
export declare type DataSourceResult<TDataSourceType extends DataSourceType> = {
|