@prismatic-io/spectral 9.0.1 → 9.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/clients/http/index.d.ts +2 -2
- package/dist/clients/http/index.js +5 -9
- package/dist/clients/http/inputs.js +2 -7
- package/dist/conditionalLogic/index.d.ts +1 -1
- package/dist/conditionalLogic/index.js +5 -10
- package/dist/conditionalLogic/types.d.ts +5 -5
- package/dist/conditionalLogic/types.js +3 -3
- package/dist/generators/componentManifest/cli.d.ts +0 -1
- package/dist/generators/componentManifest/cli.js +2 -8
- package/dist/generators/componentManifest/createActions.js +6 -6
- package/dist/generators/componentManifest/createConnections.js +6 -6
- package/dist/generators/componentManifest/createDataSources.js +6 -6
- package/dist/generators/componentManifest/createStaticFiles.js +6 -7
- package/dist/generators/componentManifest/createTriggers.js +6 -6
- package/dist/generators/componentManifest/docBlock.js +1 -3
- package/dist/generators/componentManifest/getImports.d.ts +1 -1
- package/dist/generators/componentManifest/getInputs.d.ts +4 -4
- package/dist/generators/componentManifest/getInputs.js +2 -3
- package/dist/generators/componentManifest/helpers.d.ts +1 -1
- package/dist/generators/componentManifest/index.js +1 -1
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +1 -1
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +1 -1
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +1 -1
- package/dist/generators/componentManifest/templates/partials/performArgs.ejs +1 -1
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +1 -1
- package/dist/generators/utils/createDependencyImports.d.ts +1 -1
- package/dist/generators/utils/createDependencyImports.js +1 -1
- package/dist/generators/utils/createFlagHelpText.d.ts +1 -1
- package/dist/generators/utils/createFlagHelpText.js +1 -1
- package/dist/generators/utils/createTemplate.js +2 -2
- package/dist/generators/utils/getComponentSignatureWithPrism.js +1 -1
- package/dist/generators/utils/getFlagBooleanValue.d.ts +2 -2
- package/dist/generators/utils/getFlagBooleanValue.js +2 -2
- package/dist/generators/utils/getFlagStringValue.d.ts +2 -2
- package/dist/generators/utils/getFlagStringValue.js +2 -2
- package/dist/index.d.ts +2 -16
- package/dist/serverTypes/convertComponent.js +1 -3
- package/dist/serverTypes/convertIntegration.js +33 -42
- package/dist/serverTypes/index.d.ts +11 -12
- package/dist/serverTypes/index.js +1 -1
- package/dist/serverTypes/integration.d.ts +3 -3
- package/dist/serverTypes/perform.d.ts +3 -3
- package/dist/testing.d.ts +17 -45
- package/dist/testing.js +4 -4
- package/dist/types/ActionInputParameters.d.ts +2 -2
- package/dist/types/ActionLogger.d.ts +1 -1
- package/dist/types/ActionPerformFunction.d.ts +2 -2
- package/dist/types/ActionPerformReturn.d.ts +1 -1
- package/dist/types/ComponentDefinition.d.ts +2 -2
- package/dist/types/ComponentRegistry.d.ts +16 -23
- package/dist/types/ConfigPages.d.ts +4 -4
- package/dist/types/ConfigVars.d.ts +44 -131
- package/dist/types/ConnectionDefinition.d.ts +2 -2
- package/dist/types/ConnectionDefinition.js +2 -2
- package/dist/types/DataPayload.d.ts +0 -1
- package/dist/types/DataSourcePerformFunction.d.ts +2 -2
- package/dist/types/DataSourceResult.d.ts +5 -5
- package/dist/types/DisplayDefinition.d.ts +2 -2
- package/dist/types/Inputs.d.ts +22 -22
- package/dist/types/IntegrationDefinition.d.ts +7 -7
- package/dist/types/TriggerDefinition.d.ts +1 -1
- package/dist/types/TriggerEventFunction.d.ts +2 -2
- package/dist/types/TriggerPerformFunction.d.ts +1 -1
- package/dist/types/TriggerResult.d.ts +1 -1
- package/dist/types/utils.d.ts +3 -3
- package/dist/util.d.ts +6 -6
- package/dist/util.js +4 -11
- package/package.json +9 -20
|
@@ -17,7 +17,7 @@ const ejs_1 = require("ejs");
|
|
|
17
17
|
const fs_extra_1 = require("fs-extra");
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const prettier_1 = require("prettier");
|
|
20
|
-
const createTemplate = ({ source, destination = source.replace(/\.ejs$/, ""), data = {}, dryRun, verbose, })
|
|
20
|
+
const createTemplate = (_a) => __awaiter(void 0, [_a], void 0, function* ({ source, destination = source.replace(/\.ejs$/, ""), data = {}, dryRun, verbose, }) {
|
|
21
21
|
if (!source) {
|
|
22
22
|
throw new Error("Source is required");
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ const createTemplate = ({ source, destination = source.replace(/\.ejs$/, ""), da
|
|
|
25
25
|
if (path_1.default.extname(source) === ".ejs") {
|
|
26
26
|
const render = yield (0, ejs_1.renderFile)(source, data);
|
|
27
27
|
const formattedRender = [".ts", ".js"].includes(path_1.default.extname(destination))
|
|
28
|
-
? (0, prettier_1.format)(render, {
|
|
28
|
+
? yield (0, prettier_1.format)(render, {
|
|
29
29
|
parser: "typescript",
|
|
30
30
|
})
|
|
31
31
|
: render;
|
|
@@ -13,7 +13,7 @@ exports.getComponentSignatureWithPrism = void 0;
|
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
14
|
const util_1 = require("util");
|
|
15
15
|
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
16
|
-
const getComponentSignatureWithPrism = (
|
|
16
|
+
const getComponentSignatureWithPrism = (_a) => __awaiter(void 0, [_a], void 0, function* ({ skipSignatureVerify, }) {
|
|
17
17
|
if (!(yield isPrismAvailable())) {
|
|
18
18
|
console.log("Prism must be installed.");
|
|
19
19
|
process.exit(1);
|
|
@@ -2,10 +2,10 @@ interface GetFlagBooleanValueProps {
|
|
|
2
2
|
args: string[];
|
|
3
3
|
flag: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const getFlagBooleanValue: ({ args, flag
|
|
5
|
+
export declare const getFlagBooleanValue: ({ args, flag }: GetFlagBooleanValueProps) => boolean;
|
|
6
6
|
interface GetFlagsBooleanValueProps {
|
|
7
7
|
args: string[];
|
|
8
8
|
flags: string[];
|
|
9
9
|
}
|
|
10
|
-
export declare const getFlagsBooleanValue: ({ args, flags
|
|
10
|
+
export declare const getFlagsBooleanValue: ({ args, flags }: GetFlagsBooleanValueProps) => boolean;
|
|
11
11
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFlagsBooleanValue = exports.getFlagBooleanValue = void 0;
|
|
4
|
-
const getFlagBooleanValue = ({ args, flag
|
|
4
|
+
const getFlagBooleanValue = ({ args, flag }) => {
|
|
5
5
|
return args.includes(flag);
|
|
6
6
|
};
|
|
7
7
|
exports.getFlagBooleanValue = getFlagBooleanValue;
|
|
8
|
-
const getFlagsBooleanValue = ({ args, flags
|
|
8
|
+
const getFlagsBooleanValue = ({ args, flags }) => {
|
|
9
9
|
return flags.reduce((acc, flag) => {
|
|
10
10
|
const value = (0, exports.getFlagBooleanValue)({ args, flag });
|
|
11
11
|
if (typeof value === "undefined" || acc) {
|
|
@@ -2,10 +2,10 @@ interface GetFlagStringValueProps {
|
|
|
2
2
|
args: string[];
|
|
3
3
|
flag: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const getFlagStringValue: ({ args, flag
|
|
5
|
+
export declare const getFlagStringValue: ({ args, flag }: GetFlagStringValueProps) => string | null;
|
|
6
6
|
interface GetFlagsStringValueProps {
|
|
7
7
|
args: string[];
|
|
8
8
|
flags: string[];
|
|
9
9
|
}
|
|
10
|
-
export declare const getFlagsStringValue: ({ args, flags
|
|
10
|
+
export declare const getFlagsStringValue: ({ args, flags }: GetFlagsStringValueProps) => string | null;
|
|
11
11
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFlagsStringValue = exports.getFlagStringValue = void 0;
|
|
4
|
-
const getFlagStringValue = ({ args, flag
|
|
4
|
+
const getFlagStringValue = ({ args, flag }) => {
|
|
5
5
|
const flagIndex = args.indexOf(flag);
|
|
6
6
|
if (flagIndex === -1) {
|
|
7
7
|
return null;
|
|
@@ -13,7 +13,7 @@ const getFlagStringValue = ({ args, flag, }) => {
|
|
|
13
13
|
return flagValue.replace(/(^"|"$)|(^'|'$)/g, "");
|
|
14
14
|
};
|
|
15
15
|
exports.getFlagStringValue = getFlagStringValue;
|
|
16
|
-
const getFlagsStringValue = ({ args, flags
|
|
16
|
+
const getFlagsStringValue = ({ args, flags }) => {
|
|
17
17
|
return flags.reduce((acc, flag) => {
|
|
18
18
|
const value = (0, exports.getFlagStringValue)({ args, flag });
|
|
19
19
|
if (typeof value === "undefined" || acc) {
|
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, OnPremConnectionDefinition, ComponentManifest } from "./types";
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, DataSourceType, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ComponentManifest } from "./types";
|
|
7
7
|
import { convertComponent } from "./serverTypes/convertComponent";
|
|
8
8
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
9
9
|
/**
|
|
@@ -93,21 +93,7 @@ export declare const trigger: <TInputs extends Inputs, TConfigVars extends Confi
|
|
|
93
93
|
* @param definition A DataSourceDefinition type object that includes UI display information, a function to perform when the data source is invoked, and a an object containing inputs for the perform function.
|
|
94
94
|
* @returns This function validates the shape of the `definition` object provided, and returns the same data source object.
|
|
95
95
|
*/
|
|
96
|
-
export declare const dataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends
|
|
97
|
-
string: string;
|
|
98
|
-
date: string;
|
|
99
|
-
timestamp: string;
|
|
100
|
-
picklist: string[] | import("./types").Element[];
|
|
101
|
-
schedule: {
|
|
102
|
-
value: string;
|
|
103
|
-
};
|
|
104
|
-
code: string;
|
|
105
|
-
boolean: boolean;
|
|
106
|
-
number: number;
|
|
107
|
-
objectSelection: import("./types").ObjectSelection;
|
|
108
|
-
objectFieldMap: import("./types").ObjectFieldMap;
|
|
109
|
-
jsonForm: import("./types").JSONForm;
|
|
110
|
-
}>(definition: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>) => DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>;
|
|
96
|
+
export declare const dataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends DataSourceType>(definition: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>) => DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>;
|
|
111
97
|
/**
|
|
112
98
|
* For information and examples on how to write inputs
|
|
113
99
|
* for custom component actions and triggers, see
|
|
@@ -17,9 +17,7 @@ const perform_1 = require("./perform");
|
|
|
17
17
|
const lodash_1 = require("lodash");
|
|
18
18
|
const convertInput = (key, _a) => {
|
|
19
19
|
var { default: defaultValue, type, label, collection } = _a, rest = __rest(_a, ["default", "type", "label", "collection"]);
|
|
20
|
-
const keyLabel = collection === "keyvaluelist" && typeof label === "object"
|
|
21
|
-
? label.key
|
|
22
|
-
: undefined;
|
|
20
|
+
const keyLabel = collection === "keyvaluelist" && typeof label === "object" ? label.key : undefined;
|
|
23
21
|
return Object.assign(Object.assign({}, (0, lodash_1.omit)(rest, ["onPremControlled"])), { key,
|
|
24
22
|
type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], collection, label: typeof label === "string" ? label : label.value, keyLabel, onPremiseControlled: ("onPremControlled" in rest && rest.onPremControlled) || undefined });
|
|
25
23
|
};
|
|
@@ -83,12 +83,8 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
83
83
|
const preprocessFlowConfig = hasPreprocessFlow
|
|
84
84
|
? preprocessFlows[0].preprocessFlowConfig
|
|
85
85
|
: triggerPreprocessFlowConfig;
|
|
86
|
-
const nonPreprocessFlowTypes = [
|
|
87
|
-
|
|
88
|
-
"shared_instance",
|
|
89
|
-
];
|
|
90
|
-
if (nonPreprocessFlowTypes.includes(endpointType || "flow_specific") &&
|
|
91
|
-
!preprocessFlowConfig) {
|
|
86
|
+
const nonPreprocessFlowTypes = ["instance_specific", "shared_instance"];
|
|
87
|
+
if (nonPreprocessFlowTypes.includes(endpointType || "flow_specific") && !preprocessFlowConfig) {
|
|
92
88
|
throw new Error("Integration with specified EndpointType must define either a Trigger Preprocess Flow Config or a Preprocess Flow.");
|
|
93
89
|
}
|
|
94
90
|
// Transform the IntegrationDefinition into the structure that is appropriate
|
|
@@ -159,7 +155,7 @@ const convertConfigVarPermissionAndVisibility = ({ permissionAndVisibilityType,
|
|
|
159
155
|
},
|
|
160
156
|
};
|
|
161
157
|
};
|
|
162
|
-
const convertComponentReference = (componentReference, componentRegistry) => {
|
|
158
|
+
const convertComponentReference = (componentReference, componentRegistry, referenceType) => {
|
|
163
159
|
var _a, _b;
|
|
164
160
|
const manifest = componentRegistry[componentReference.component];
|
|
165
161
|
if (!manifest) {
|
|
@@ -173,21 +169,25 @@ const convertComponentReference = (componentReference, componentRegistry) => {
|
|
|
173
169
|
},
|
|
174
170
|
key: componentReference.key,
|
|
175
171
|
};
|
|
172
|
+
const manifestEntry = manifest[referenceType][componentReference.key];
|
|
176
173
|
const inputs = Object.entries((_b = componentReference.values) !== null && _b !== void 0 ? _b : {}).reduce((result, [key, value]) => {
|
|
174
|
+
const manifestEntryInput = manifestEntry.inputs[key];
|
|
175
|
+
const type = manifestEntryInput.collection
|
|
176
|
+
? "complex"
|
|
177
|
+
: "value" in value
|
|
178
|
+
? "value"
|
|
179
|
+
: "configVar";
|
|
177
180
|
if ("value" in value) {
|
|
178
|
-
const
|
|
179
|
-
const valueExpr = value.value instanceof Object && !Array.isArray(value.value)
|
|
181
|
+
const valueExpr = manifestEntryInput.collection === "keyvaluelist" && value.value instanceof Object
|
|
180
182
|
? Object.entries(value.value).map(([k, v]) => ({
|
|
181
183
|
name: { type: "value", value: k },
|
|
182
184
|
type: "value",
|
|
183
185
|
value: v,
|
|
184
186
|
}))
|
|
185
187
|
: value.value;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
]));
|
|
190
|
-
return Object.assign(Object.assign({}, result), { [key]: { type: type, value: valueExpr, meta } });
|
|
188
|
+
const formattedValue = type === "complex" || typeof valueExpr === "string" ? valueExpr : JSON.stringify(valueExpr);
|
|
189
|
+
const meta = convertInputPermissionAndVisibility((0, lodash_1.pick)(value, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
|
|
190
|
+
return Object.assign(Object.assign({}, result), { [key]: { type: type, value: formattedValue, meta } });
|
|
191
191
|
}
|
|
192
192
|
if ("configVar" in value) {
|
|
193
193
|
return Object.assign(Object.assign({}, result), { [key]: { type: "configVar", value: value.configVar } });
|
|
@@ -219,13 +219,13 @@ const codeNativeIntegrationComponentReference = (referenceKey) => ({
|
|
|
219
219
|
const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
220
220
|
var _a;
|
|
221
221
|
const result = Object.assign({}, flow);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
result.onTrigger = undefined;
|
|
223
|
+
result.trigger = undefined;
|
|
224
|
+
result.onInstanceDeploy = undefined;
|
|
225
|
+
result.onInstanceDelete = undefined;
|
|
226
|
+
result.onExecution = undefined;
|
|
227
|
+
result.preprocessFlowConfig = undefined;
|
|
228
|
+
result.errorConfig = undefined;
|
|
229
229
|
const triggerStep = {
|
|
230
230
|
name: "On Trigger",
|
|
231
231
|
stableKey: `${flow.stableKey}-onTrigger`,
|
|
@@ -240,7 +240,7 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
242
|
else if ((0, types_1.isComponentReference)(flow.onTrigger)) {
|
|
243
|
-
const { ref, inputs } = convertComponentReference(flow.onTrigger, componentRegistry);
|
|
243
|
+
const { ref, inputs } = convertComponentReference(flow.onTrigger, componentRegistry, "triggers");
|
|
244
244
|
triggerStep.action = ref;
|
|
245
245
|
triggerStep.inputs = inputs;
|
|
246
246
|
}
|
|
@@ -269,7 +269,7 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
269
269
|
timeZone: (_a = schedule.timezone) !== null && _a !== void 0 ? _a : "",
|
|
270
270
|
},
|
|
271
271
|
};
|
|
272
|
-
|
|
272
|
+
result.schedule = undefined;
|
|
273
273
|
}
|
|
274
274
|
const actionStep = {
|
|
275
275
|
action: {
|
|
@@ -295,17 +295,14 @@ const convertInputValue = (value, collectionType) => {
|
|
|
295
295
|
}
|
|
296
296
|
return Object.entries(value).map(([key, value]) => ({
|
|
297
297
|
key,
|
|
298
|
-
value,
|
|
298
|
+
value: typeof value === "string" ? value : JSON.stringify(value),
|
|
299
299
|
}));
|
|
300
300
|
};
|
|
301
301
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
302
302
|
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
303
303
|
const { orgOnly, meta } = convertConfigVarPermissionAndVisibility((0, lodash_1.pick)(configVar, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
|
|
304
304
|
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
305
|
-
const { stableKey, description } = (0, lodash_1.pick)(configVar, [
|
|
306
|
-
"stableKey",
|
|
307
|
-
"description",
|
|
308
|
-
]);
|
|
305
|
+
const { stableKey, description } = (0, lodash_1.pick)(configVar, ["stableKey", "description"]);
|
|
309
306
|
return {
|
|
310
307
|
stableKey,
|
|
311
308
|
description,
|
|
@@ -330,7 +327,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
330
327
|
};
|
|
331
328
|
}
|
|
332
329
|
if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
|
|
333
|
-
const { ref, inputs } = convertComponentReference(configVar.connection, componentRegistry);
|
|
330
|
+
const { ref, inputs } = convertComponentReference(configVar.connection, componentRegistry, "connections");
|
|
334
331
|
const { stableKey = "", description, connection: { template, onPremiseConnectionConfig }, } = (0, lodash_1.pick)(configVar, ["stableKey", "description", "connection"]);
|
|
335
332
|
return {
|
|
336
333
|
stableKey,
|
|
@@ -372,18 +369,15 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
372
369
|
};
|
|
373
370
|
}
|
|
374
371
|
if ((0, types_1.isDataSourceReferenceConfigVar)(configVar)) {
|
|
375
|
-
const { ref, inputs } = convertComponentReference(configVar.dataSource, componentRegistry);
|
|
376
|
-
result.dataType =
|
|
377
|
-
componentRegistry[ref.component.key]["dataSources"][ref.key]["dataSourceType"];
|
|
372
|
+
const { ref, inputs } = convertComponentReference(configVar.dataSource, componentRegistry, "dataSources");
|
|
373
|
+
result.dataType = componentRegistry[ref.component.key].dataSources[ref.key].dataSourceType;
|
|
378
374
|
result.dataSource = ref;
|
|
379
375
|
result.inputs = inputs;
|
|
380
376
|
}
|
|
381
377
|
return result;
|
|
382
378
|
};
|
|
383
379
|
/** Maps the step name field to a fully qualified input. */
|
|
384
|
-
const fieldNameToReferenceInput = (stepName, fieldName) => fieldName
|
|
385
|
-
? { type: "reference", value: `${stepName}.results.${fieldName}` }
|
|
386
|
-
: undefined;
|
|
380
|
+
const fieldNameToReferenceInput = (stepName, fieldName) => fieldName ? { type: "reference", value: `${stepName}.results.${fieldName}` } : undefined;
|
|
387
381
|
/** Actions and Triggers will be scoped to their flow by combining the flow
|
|
388
382
|
* name and the function name. This is to ensure that the keys are unique
|
|
389
383
|
* on the resulting object, which will be turned into a Component. */
|
|
@@ -392,9 +386,7 @@ const flowFunctionKey = (flowName, functionName) => {
|
|
|
392
386
|
.replace(/[^0-9a-zA-Z]+/g, " ")
|
|
393
387
|
.trim()
|
|
394
388
|
.split(" ")
|
|
395
|
-
.map((w, i) => i === 0
|
|
396
|
-
? w.toLowerCase()
|
|
397
|
-
: w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
389
|
+
.map((w, i) => i === 0 ? w.toLowerCase() : w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
398
390
|
.join("");
|
|
399
391
|
return `${flowKey}_${functionName}`;
|
|
400
392
|
};
|
|
@@ -402,10 +394,9 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
|
|
|
402
394
|
const {
|
|
403
395
|
// @ts-expect-error _components isn't part of the public API
|
|
404
396
|
_components } = context, remainingContext = __rest(context, ["_components"]);
|
|
405
|
-
const invoke = _components
|
|
406
|
-
.invoke;
|
|
397
|
+
const invoke = _components.invoke;
|
|
407
398
|
// Construct the component methods from the component registry
|
|
408
|
-
const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature }
|
|
399
|
+
const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature }]) => {
|
|
409
400
|
const componentActions = Object.entries(actions).reduce((actionsAccumulator, [actionKey, action]) => {
|
|
410
401
|
// Define the method to be called for the action
|
|
411
402
|
const invokeAction = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -432,7 +423,7 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
|
|
|
432
423
|
};
|
|
433
424
|
/** Creates the structure necessary to import a Component as part of a
|
|
434
425
|
* Code Native integration. */
|
|
435
|
-
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], componentRegistry = {}
|
|
426
|
+
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], componentRegistry = {} }, referenceKey, configVars) => {
|
|
436
427
|
const convertedActions = flows.reduce((result, { name, onExecution }) => {
|
|
437
428
|
const key = flowFunctionKey(name, "onExecution");
|
|
438
429
|
return Object.assign(Object.assign({}, result), { [key]: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { InstanceAttributes, CustomerAttributes, DataSourceType, DataSourceResultType, UserAttributes, TriggerEventFunctionReturn, IntegrationAttributes, FlowAttributes, ConfigVarResultCollection, ComponentManifest } from "../types";
|
|
3
2
|
interface DisplayDefinition {
|
|
4
3
|
label: string;
|
|
@@ -38,7 +37,7 @@ export interface Action {
|
|
|
38
37
|
perform: ActionPerformFunction;
|
|
39
38
|
examplePayload?: unknown;
|
|
40
39
|
}
|
|
41
|
-
export
|
|
40
|
+
export type ActionLoggerFunction = (...args: unknown[]) => void;
|
|
42
41
|
export interface ActionLogger {
|
|
43
42
|
metric: ActionLoggerFunction;
|
|
44
43
|
trace: ActionLoggerFunction;
|
|
@@ -48,7 +47,7 @@ export interface ActionLogger {
|
|
|
48
47
|
warn: ActionLoggerFunction;
|
|
49
48
|
error: ActionLoggerFunction;
|
|
50
49
|
}
|
|
51
|
-
export
|
|
50
|
+
export type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]> = Record<string, ComponentManifest["actions"]>> = {
|
|
52
51
|
logger: ActionLogger;
|
|
53
52
|
instanceState: Record<string, unknown>;
|
|
54
53
|
crossFlowState: Record<string, unknown>;
|
|
@@ -72,7 +71,7 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
|
72
71
|
flow: FlowAttributes;
|
|
73
72
|
startedAt: string;
|
|
74
73
|
};
|
|
75
|
-
|
|
74
|
+
type TriggerOptionChoice = "invalid" | "valid" | "required";
|
|
76
75
|
export interface TriggerPayload {
|
|
77
76
|
headers: Record<string, string>;
|
|
78
77
|
queryParameters: Record<string, string>;
|
|
@@ -115,10 +114,10 @@ interface TriggerBaseResult {
|
|
|
115
114
|
interface TriggerBranchingResult extends TriggerBaseResult {
|
|
116
115
|
branch: string;
|
|
117
116
|
}
|
|
118
|
-
export
|
|
119
|
-
export
|
|
120
|
-
export
|
|
121
|
-
export
|
|
117
|
+
export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
118
|
+
export type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>;
|
|
119
|
+
export type TriggerEventFunctionResult = TriggerEventFunctionReturn | void;
|
|
120
|
+
export type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>;
|
|
122
121
|
export interface Trigger {
|
|
123
122
|
key: string;
|
|
124
123
|
display: DisplayDefinition & {
|
|
@@ -148,14 +147,14 @@ export interface DataSourceContext<TConfigVars extends ConfigVarResultCollection
|
|
|
148
147
|
instance: InstanceAttributes;
|
|
149
148
|
user: UserAttributes;
|
|
150
149
|
}
|
|
151
|
-
export
|
|
150
|
+
export type DataSourceResult = {
|
|
152
151
|
result: DataSourceResultType;
|
|
153
152
|
supplementalData?: {
|
|
154
153
|
data: unknown;
|
|
155
154
|
contentType: string;
|
|
156
155
|
};
|
|
157
156
|
};
|
|
158
|
-
export
|
|
157
|
+
export type DataSourcePerformFunction = (context: DataSourceContext, params: Record<string, unknown>) => Promise<DataSourceResult>;
|
|
159
158
|
export interface DataSource {
|
|
160
159
|
key: string;
|
|
161
160
|
display: DisplayDefinition & {
|
|
@@ -221,8 +220,8 @@ interface ServerPerformBranchingDataStructureReturn extends ServerPerformDataStr
|
|
|
221
220
|
interface ServerPerformBranchingDataReturn extends ServerPerformDataReturn {
|
|
222
221
|
branch: string;
|
|
223
222
|
}
|
|
224
|
-
export
|
|
225
|
-
export
|
|
223
|
+
export type ActionPerformReturn = ServerPerformDataStructureReturn | ServerPerformBranchingDataStructureReturn | ServerPerformDataReturn | ServerPerformBranchingDataReturn | undefined;
|
|
224
|
+
export type ActionPerformFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<ActionPerformReturn>;
|
|
226
225
|
interface InputFieldChoice {
|
|
227
226
|
label: string;
|
|
228
227
|
value: string;
|
|
@@ -5,4 +5,4 @@ var OAuth2Type;
|
|
|
5
5
|
(function (OAuth2Type) {
|
|
6
6
|
OAuth2Type["ClientCredentials"] = "client_credentials";
|
|
7
7
|
OAuth2Type["AuthorizationCode"] = "authorization_code";
|
|
8
|
-
})(OAuth2Type
|
|
8
|
+
})(OAuth2Type || (exports.OAuth2Type = OAuth2Type = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const DefinitionVersion = 7;
|
|
2
|
-
export
|
|
2
|
+
export type ComponentReference = {
|
|
3
3
|
component: {
|
|
4
4
|
key: string;
|
|
5
5
|
version: number | "LATEST";
|
|
@@ -18,7 +18,7 @@ export declare type ComponentReference = {
|
|
|
18
18
|
template?: string;
|
|
19
19
|
onPremiseConnectionConfig?: string;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type Input = {
|
|
22
22
|
name?: string | Input;
|
|
23
23
|
type: "value" | "reference" | "configVar" | "template";
|
|
24
24
|
value: string;
|
|
@@ -55,7 +55,7 @@ export interface DefaultRequiredConfigVariable {
|
|
|
55
55
|
inputs?: Record<string, Input>;
|
|
56
56
|
meta?: Record<string, unknown>;
|
|
57
57
|
}
|
|
58
|
-
export
|
|
58
|
+
export type RequiredConfigVariable = DefaultRequiredConfigVariable | ConnectionRequiredConfigVariable;
|
|
59
59
|
export interface ConfigPage {
|
|
60
60
|
name: string;
|
|
61
61
|
tagline?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ErrorHandler } from "../types";
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
type PerformFn = (...args: any[]) => Promise<any>;
|
|
3
|
+
export type CleanFn = (...args: any[]) => any;
|
|
4
|
+
export type InputCleaners = Record<string, CleanFn | undefined>;
|
|
5
5
|
interface CreatePerformProps {
|
|
6
6
|
inputCleaners: InputCleaners;
|
|
7
7
|
errorHandler?: ErrorHandler;
|
package/dist/testing.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
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 } from "./types";
|
|
9
|
-
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown>
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceType, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection } from "./types";
|
|
9
|
+
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown>) => ConnectionValue;
|
|
10
10
|
export declare const defaultConnectionValueEnvironmentVariable = "PRISMATIC_CONNECTION_VALUE";
|
|
11
11
|
export declare const connectionValue: (envVarKey?: string) => ConnectionValue;
|
|
12
12
|
/**
|
|
@@ -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
|
|
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>>) => Promise<InvokeReturn<TReturn>>;
|
|
31
31
|
export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
32
32
|
/**
|
|
33
33
|
* Invokes specified TriggerDefinition perform function using supplied params
|
|
@@ -35,40 +35,26 @@ 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
|
|
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>>, payload?: TriggerPayload, params?: ActionInputParameters<TInputs>) => 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
|
|
42
42
|
* casting within test methods. Returns a DataSourceResult.
|
|
43
43
|
*/
|
|
44
|
-
export declare const invokeDataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
picklist: string[] | import("./types").Element[];
|
|
49
|
-
schedule: {
|
|
50
|
-
value: string;
|
|
51
|
-
};
|
|
52
|
-
code: string;
|
|
53
|
-
boolean: boolean;
|
|
54
|
-
number: number;
|
|
55
|
-
objectSelection: import("./types").ObjectSelection;
|
|
56
|
-
objectFieldMap: import("./types").ObjectFieldMap;
|
|
57
|
-
jsonForm: import("./types").JSONForm;
|
|
58
|
-
}>({ perform }: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext<TConfigVars>> | undefined) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
59
|
-
declare type TestConnectionValue = Pick<ConnectionValue, "fields" | "context" | "token">;
|
|
60
|
-
declare type TestConfigVarValues = Record<string, string | TestConnectionValue>;
|
|
61
|
-
declare type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
44
|
+
export declare const invokeDataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends DataSourceType>({ perform }: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext<TConfigVars>>) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
45
|
+
type TestConnectionValue = Pick<ConnectionValue, "fields" | "context" | "token">;
|
|
46
|
+
type TestConfigVarValues = Record<string, string | TestConnectionValue>;
|
|
47
|
+
type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
62
48
|
[K in keyof TConfigVars]: TConfigVars[K] extends ConnectionDefinition ? TestConnectionValue : string;
|
|
63
49
|
};
|
|
64
50
|
/**
|
|
65
51
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
66
52
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
67
53
|
*/
|
|
68
|
-
export declare const invokeFlow: <TConfigVars extends
|
|
69
|
-
configVars?: TConfigVarValues
|
|
70
|
-
context?: Partial<ActionContext<TConfigVars
|
|
71
|
-
payload?: Partial<TriggerPayload
|
|
54
|
+
export declare const invokeFlow: <TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow, { configVars, context, payload, }?: {
|
|
55
|
+
configVars?: TConfigVarValues;
|
|
56
|
+
context?: Partial<ActionContext<TConfigVars>>;
|
|
57
|
+
payload?: Partial<TriggerPayload>;
|
|
72
58
|
}) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
73
59
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
74
60
|
component: TComponent;
|
|
@@ -76,31 +62,17 @@ export declare class ComponentTestHarness<TComponent extends Component> {
|
|
|
76
62
|
private buildParams;
|
|
77
63
|
connectionValue({ key }: ConnectionDefinition): ConnectionValue;
|
|
78
64
|
trigger<TConfigVars extends ConfigVarResultCollection>(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerResult>;
|
|
79
|
-
triggerOnInstanceDeploy<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<
|
|
80
|
-
triggerOnInstanceDelete<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<
|
|
65
|
+
triggerOnInstanceDeploy<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerEventFunctionReturn | void>;
|
|
66
|
+
triggerOnInstanceDelete<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerEventFunctionReturn | void>;
|
|
81
67
|
action<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<ActionPerformReturn>;
|
|
82
68
|
dataSource<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<DataSourceContext<TConfigVars>>): Promise<DataSourceResult>;
|
|
83
69
|
}
|
|
84
70
|
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
85
71
|
declare const _default: {
|
|
86
72
|
loggerMock: () => ActionLogger;
|
|
87
|
-
invoke: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform
|
|
88
|
-
invokeTrigger: <
|
|
73
|
+
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>>) => Promise<InvokeReturn<TReturn>>;
|
|
74
|
+
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>>, payload?: TriggerPayload, params?: ActionInputParameters<TInputs>) => Promise<InvokeReturn<TResult>>;
|
|
89
75
|
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
90
|
-
invokeDataSource: <
|
|
91
|
-
string: string;
|
|
92
|
-
date: string;
|
|
93
|
-
timestamp: string;
|
|
94
|
-
picklist: string[] | import("./types").Element[];
|
|
95
|
-
schedule: {
|
|
96
|
-
value: string;
|
|
97
|
-
};
|
|
98
|
-
code: string;
|
|
99
|
-
boolean: boolean;
|
|
100
|
-
number: number;
|
|
101
|
-
objectSelection: import("./types").ObjectSelection;
|
|
102
|
-
objectFieldMap: import("./types").ObjectFieldMap;
|
|
103
|
-
jsonForm: import("./types").JSONForm;
|
|
104
|
-
}>({ perform }: DataSourceDefinition<TInputs_2, TConfigVars_2, TDataSourceType>, params: ActionInputParameters<TInputs_2>, context?: Partial<DataSourceContext<TConfigVars_2>> | undefined) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
76
|
+
invokeDataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends DataSourceType>({ perform }: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext<TConfigVars>>) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
105
77
|
};
|
|
106
78
|
export default _default;
|
package/dist/testing.js
CHANGED
|
@@ -96,7 +96,7 @@ const createDataSourceContext = (context) => {
|
|
|
96
96
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
97
97
|
* action result and a mock logger for asserting logging.
|
|
98
98
|
*/
|
|
99
|
-
const invoke = (
|
|
99
|
+
const invoke = (_a, params_1, context_1) => __awaiter(void 0, [_a, params_1, context_1], void 0, function* ({ perform }, params, context) {
|
|
100
100
|
const realizedContext = createActionContext(context);
|
|
101
101
|
const result = yield perform(realizedContext, params);
|
|
102
102
|
return {
|
|
@@ -165,7 +165,7 @@ exports.defaultTriggerPayload = defaultTriggerPayload;
|
|
|
165
165
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
166
166
|
* trigger result and a mock logger for asserting logging.
|
|
167
167
|
*/
|
|
168
|
-
const invokeTrigger = (
|
|
168
|
+
const invokeTrigger = (_a, context_1, payload_1, params_1) => __awaiter(void 0, [_a, context_1, payload_1, params_1], void 0, function* ({ perform }, context, payload, params) {
|
|
169
169
|
const realizedContext = createActionContext(context);
|
|
170
170
|
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
|
|
171
171
|
const realizedParams = params || {};
|
|
@@ -181,7 +181,7 @@ exports.invokeTrigger = invokeTrigger;
|
|
|
181
181
|
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
182
182
|
* casting within test methods. Returns a DataSourceResult.
|
|
183
183
|
*/
|
|
184
|
-
const invokeDataSource = (
|
|
184
|
+
const invokeDataSource = (_a, params_1, context_1) => __awaiter(void 0, [_a, params_1, context_1], void 0, function* ({ perform }, params, context) {
|
|
185
185
|
const realizedContext = createDataSourceContext(context);
|
|
186
186
|
const result = yield perform(realizedContext, params);
|
|
187
187
|
return result;
|
|
@@ -200,7 +200,7 @@ const createConfigVars = (values) => {
|
|
|
200
200
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
201
201
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
202
202
|
*/
|
|
203
|
-
const invokeFlow = (
|
|
203
|
+
const invokeFlow = (flow_1, ...args_1) => __awaiter(void 0, [flow_1, ...args_1], void 0, function* (flow, { configVars, context, payload, } = {}) {
|
|
204
204
|
const realizedConfigVars = createConfigVars(configVars);
|
|
205
205
|
const realizedContext = createActionContext(Object.assign(Object.assign({}, context), { configVars: realizedConfigVars }));
|
|
206
206
|
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
|
|
@@ -6,7 +6,7 @@ import { InputFieldCollection, InputCleanFunction, Connection, KeyValuePair } fr
|
|
|
6
6
|
* Inputs can be static values, references to config variables, or
|
|
7
7
|
* references to previous steps' outputs.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type ActionInputParameters<TInputs extends Inputs> = {
|
|
10
10
|
[Property in keyof TInputs]: TInputs[Property]["clean"] extends InputCleanFunction<any> ? ReturnType<TInputs[Property]["clean"]> : TInputs[Property]["type"] extends "connection" ? ExtractValue<Connection, TInputs[Property]["collection"]> : TInputs[Property]["type"] extends "conditional" ? ExtractValue<ConditionalExpression, TInputs[Property]["collection"]> : ExtractValue<TInputs[Property]["default"], TInputs[Property]["collection"]>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type ExtractValue<TType, TCollection extends InputFieldCollection | undefined> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] : TCollection extends "valuelist" ? TType[] : TType;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* A logger function, similar to `console.log()` or `console.error()`.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type ActionLoggerFunction = (...args: unknown[]) => void;
|
|
11
11
|
/**
|
|
12
12
|
* An object containing logger functions.
|
|
13
13
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
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
|
|
3
|
+
export 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
|
|
5
|
+
export 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 */
|