@prismatic-io/spectral 9.0.0-rc.4 → 9.0.0-rc.5
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/generators/componentManifest/cli.js +14 -13
- package/dist/generators/componentManifest/getInputs.js +10 -1
- package/dist/generators/componentManifest/index.d.ts +2 -2
- package/dist/generators/componentManifest/index.js +4 -4
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +9 -4
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +9 -4
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +9 -4
- package/dist/generators/componentManifest/templates/partials/inputs.ejs +19 -0
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +9 -4
- package/dist/generators/utils/getComponentSignatureWithPrism.d.ts +5 -1
- package/dist/generators/utils/getComponentSignatureWithPrism.js +4 -4
- package/dist/serverTypes/convertIntegration.js +145 -28
- package/dist/serverTypes/index.d.ts +5 -1
- package/dist/types/ActionPerformFunction.d.ts +5 -1
- package/dist/types/ComponentManifest.d.ts +28 -4
- package/dist/types/IntegrationDefinition.d.ts +24 -7
- package/package.json +1 -1
- /package/dist/generators/componentManifest/templates/partials/{inputTypes.ejs → performArgs.ejs} +0 -0
|
@@ -45,11 +45,12 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
45
45
|
console.error("Component is invalid.");
|
|
46
46
|
process.exit(1);
|
|
47
47
|
}
|
|
48
|
+
const args = process.argv.slice(3);
|
|
48
49
|
const flags = {
|
|
49
50
|
name: {
|
|
50
51
|
flag: ["--name", "-n"],
|
|
51
52
|
value: (0, getFlagStringValue_1.getFlagsStringValue)({
|
|
52
|
-
args
|
|
53
|
+
args,
|
|
53
54
|
flags: ["--name", "-n"],
|
|
54
55
|
}),
|
|
55
56
|
description: "The name of the component manifest. Defaults to the name of the current component being generated.",
|
|
@@ -57,7 +58,7 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
57
58
|
verbose: {
|
|
58
59
|
flag: ["--verbose", "-v"],
|
|
59
60
|
value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
|
|
60
|
-
args
|
|
61
|
+
args,
|
|
61
62
|
flags: ["--verbose", "-v"],
|
|
62
63
|
}),
|
|
63
64
|
description: "Provides more detailed or extensive information about the files being generated during the process.",
|
|
@@ -65,7 +66,7 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
65
66
|
output_dir: {
|
|
66
67
|
flag: ["--output-dir", "-o"],
|
|
67
68
|
value: (0, getFlagStringValue_1.getFlagsStringValue)({
|
|
68
|
-
args
|
|
69
|
+
args,
|
|
69
70
|
flags: ["--output-dir", "-o"],
|
|
70
71
|
}),
|
|
71
72
|
description: "The output directory for the component manifest. Defaults to the sibling of the current component directory.",
|
|
@@ -73,7 +74,7 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
73
74
|
registry: {
|
|
74
75
|
flag: ["--registry", "-r"],
|
|
75
76
|
value: (0, getFlagStringValue_1.getFlagsStringValue)({
|
|
76
|
-
args
|
|
77
|
+
args,
|
|
77
78
|
flags: ["--registry", "-r"],
|
|
78
79
|
}),
|
|
79
80
|
description: "The registry to publish the component manifest to (as a URI). This is where your package will be published. If not specified, it defaults to your system's default registry.",
|
|
@@ -81,23 +82,23 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
81
82
|
dry_run: {
|
|
82
83
|
flag: ["--dry-run", "-d"],
|
|
83
84
|
value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
|
|
84
|
-
args
|
|
85
|
+
args,
|
|
85
86
|
flags: ["--dry-run", "-d"],
|
|
86
87
|
}),
|
|
87
88
|
description: "Perform a dry run without generating the component manifest. This provides a preview of what you could expect to happen when running the command without this flag.",
|
|
88
89
|
},
|
|
89
|
-
|
|
90
|
-
flag: ["--
|
|
90
|
+
skip_signature_verify: {
|
|
91
|
+
flag: ["--skip-signature-verify"],
|
|
91
92
|
value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
|
|
92
|
-
args
|
|
93
|
-
flags: ["--
|
|
93
|
+
args,
|
|
94
|
+
flags: ["--skip-signature-verify"],
|
|
94
95
|
}),
|
|
95
|
-
description: "This
|
|
96
|
+
description: "This skips the signature verification process, always returning a component signature in the component manifest.",
|
|
96
97
|
},
|
|
97
98
|
help: {
|
|
98
99
|
flag: ["--help", "-h"],
|
|
99
100
|
value: (0, getFlagBooleanValue_1.getFlagsBooleanValue)({
|
|
100
|
-
args
|
|
101
|
+
args,
|
|
101
102
|
flags: ["--help", "-h"],
|
|
102
103
|
}),
|
|
103
104
|
description: "Show this help message.",
|
|
@@ -114,8 +115,8 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
114
115
|
yield (0, index_1.createComponentManifest)({
|
|
115
116
|
component,
|
|
116
117
|
dryRun: flags.dry_run.value,
|
|
117
|
-
|
|
118
|
-
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@
|
|
118
|
+
skipSignatureVerify: flags.skip_signature_verify.value,
|
|
119
|
+
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@component-manifests/${component.key}`,
|
|
119
120
|
dependencies: {
|
|
120
121
|
spectral: packageJson.version,
|
|
121
122
|
dependencies: packageJson.dependencies,
|
|
@@ -8,6 +8,8 @@ const getInputs = ({ inputs, documentProperties, }) => {
|
|
|
8
8
|
label: input.label,
|
|
9
9
|
type: getInputType(input),
|
|
10
10
|
required: input.required,
|
|
11
|
+
collection: input.collection,
|
|
12
|
+
inputType: input.type,
|
|
11
13
|
properties: documentProperties.reduce((acc, key) => {
|
|
12
14
|
const value = input[key]
|
|
13
15
|
? JSON.stringify(input[key])
|
|
@@ -60,7 +62,14 @@ exports.INPUT_TYPE_MAP = {
|
|
|
60
62
|
dynamicFieldSelection: "string",
|
|
61
63
|
};
|
|
62
64
|
const getInputType = (input) => {
|
|
63
|
-
|
|
65
|
+
const valueType = input.model
|
|
64
66
|
? input.model.map((choice) => `"${choice.value}"`).join(" | ")
|
|
65
67
|
: exports.INPUT_TYPE_MAP[input.type] || "never";
|
|
68
|
+
if (input.collection === "keyvaluelist") {
|
|
69
|
+
return `Record<string, ${valueType}>`;
|
|
70
|
+
}
|
|
71
|
+
if (input.collection === "valuelist") {
|
|
72
|
+
return `${valueType}[]`;
|
|
73
|
+
}
|
|
74
|
+
return valueType;
|
|
66
75
|
};
|
|
@@ -3,7 +3,7 @@ import { Component } from "../../serverTypes";
|
|
|
3
3
|
interface CreateComponentManifestProps {
|
|
4
4
|
component: Component;
|
|
5
5
|
dryRun: boolean;
|
|
6
|
-
|
|
6
|
+
skipSignatureVerify: boolean;
|
|
7
7
|
packageName: string;
|
|
8
8
|
dependencies: PackageDependencies;
|
|
9
9
|
verbose: boolean;
|
|
@@ -11,5 +11,5 @@ interface CreateComponentManifestProps {
|
|
|
11
11
|
destinationDir: string;
|
|
12
12
|
registry: string | null;
|
|
13
13
|
}
|
|
14
|
-
export declare const createComponentManifest: ({ component, dryRun,
|
|
14
|
+
export declare const createComponentManifest: ({ component, dryRun, skipSignatureVerify, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateComponentManifestProps) => Promise<void>;
|
|
15
15
|
export {};
|
|
@@ -21,10 +21,10 @@ const createStaticFiles_1 = require("./createStaticFiles");
|
|
|
21
21
|
const createTriggers_1 = require("./createTriggers");
|
|
22
22
|
const removeComponentManifest_1 = require("./removeComponentManifest");
|
|
23
23
|
const getComponentSignatureWithPrism_1 = require("../utils/getComponentSignatureWithPrism");
|
|
24
|
-
const createComponentManifest = ({ component, dryRun,
|
|
25
|
-
const signature =
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const createComponentManifest = ({ component, dryRun, skipSignatureVerify, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const signature = yield (0, getComponentSignatureWithPrism_1.getComponentSignatureWithPrism)({
|
|
26
|
+
skipSignatureVerify,
|
|
27
|
+
});
|
|
28
28
|
if (verbose) {
|
|
29
29
|
console.info(`Creating a component manifest for ${component.display.label}...`);
|
|
30
30
|
console.log("");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(action.key) %>Values {
|
|
4
|
-
<%- include('../partials/
|
|
4
|
+
<%- include('../partials/performArgs.ejs', { inputs: action.inputs }) -%>
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,6 +9,11 @@ export interface <%= helpers.capitalizeFirstLetter(action.key) %>Values {
|
|
|
9
9
|
*
|
|
10
10
|
* @description <%= action.description %>
|
|
11
11
|
*/
|
|
12
|
-
export const <%= action.key %> =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const <%= action.key %> = {
|
|
13
|
+
perform: <TReturn>(
|
|
14
|
+
_values: <%= helpers.capitalizeFirstLetter(action.key) %>Values
|
|
15
|
+
): Promise<TReturn> => Promise.resolve<TReturn>({} as TReturn),
|
|
16
|
+
inputs: {
|
|
17
|
+
<%- include('../partials/inputs.ejs', { inputs: action.inputs }) -%>
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(connection.key) %>Values {
|
|
4
|
-
<%- include('../partials/
|
|
4
|
+
<%- include('../partials/performArgs.ejs', { inputs: connection.inputs }) -%>
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,6 +9,11 @@ export interface <%= helpers.capitalizeFirstLetter(connection.key) %>Values {
|
|
|
9
9
|
*
|
|
10
10
|
* @comments <%= connection.comments %>
|
|
11
11
|
*/
|
|
12
|
-
export const <%= connection.key %> =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const <%= connection.key %> = {
|
|
13
|
+
perform: (
|
|
14
|
+
_values: <%= helpers.capitalizeFirstLetter(connection.key) %>Values
|
|
15
|
+
): Promise<void> => Promise.resolve(),
|
|
16
|
+
inputs: {
|
|
17
|
+
<%- include('../partials/inputs.ejs', { inputs: connection.inputs }) -%>
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values {
|
|
4
|
-
<%- include('../partials/
|
|
4
|
+
<%- include('../partials/performArgs.ejs', { inputs: dataSource.inputs }) -%>
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,6 +9,11 @@ export interface <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values {
|
|
|
9
9
|
*
|
|
10
10
|
* @description <%= dataSource.description %>
|
|
11
11
|
*/
|
|
12
|
-
export const <%= dataSource.key %> =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const <%= dataSource.key %> = {
|
|
13
|
+
perform: (
|
|
14
|
+
_values: <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values
|
|
15
|
+
): Promise<void> => Promise.resolve(),
|
|
16
|
+
inputs: {
|
|
17
|
+
<%- include('../partials/inputs.ejs', { inputs: dataSource.inputs }) -%>
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<% inputs.forEach((input) => { -%>
|
|
2
|
+
<%= input.key %>: {
|
|
3
|
+
inputType: "<%= input.defaultType %>",
|
|
4
|
+
<%_ if (input.collection) { -%>
|
|
5
|
+
collection: "<%= input.collection %>" as const,
|
|
6
|
+
<%_ } else { -%>
|
|
7
|
+
collection: null,
|
|
8
|
+
<%_ } -%>
|
|
9
|
+
<%_ if (input.default) { -%>
|
|
10
|
+
default: <%= input.default %>,
|
|
11
|
+
<%_ } -%>
|
|
12
|
+
<%_ if (input.required) { -%>
|
|
13
|
+
required: <%= input.required %>,
|
|
14
|
+
<%_ } -%>
|
|
15
|
+
<%_ if (typeof input.onPremiseControlled !== "undefined") { -%>
|
|
16
|
+
onPremiseControlled: <%= input.onPremiseControlled %>,
|
|
17
|
+
<%_ } -%>
|
|
18
|
+
},
|
|
19
|
+
<% }); -%>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(trigger.key) %>Values {
|
|
4
|
-
<%- include('../partials/
|
|
4
|
+
<%- include('../partials/performArgs.ejs', { inputs: trigger.inputs }) -%>
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -9,6 +9,11 @@ export interface <%= helpers.capitalizeFirstLetter(trigger.key) %>Values {
|
|
|
9
9
|
*
|
|
10
10
|
* @description <%= trigger.description %>
|
|
11
11
|
*/
|
|
12
|
-
export const <%= trigger.key %> =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export const <%= trigger.key %> = {
|
|
13
|
+
perform: <TReturn>(
|
|
14
|
+
_values: <%= helpers.capitalizeFirstLetter(trigger.key) %>Values
|
|
15
|
+
): Promise<TReturn> => Promise.resolve<TReturn>({} as TReturn),
|
|
16
|
+
inputs: {
|
|
17
|
+
<%- include('../partials/inputs.ejs', { inputs: trigger.inputs }) -%>
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
interface GetComponentSignatureWithPrismProps {
|
|
2
|
+
skipSignatureVerify: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare const getComponentSignatureWithPrism: ({ skipSignatureVerify, }: GetComponentSignatureWithPrismProps) => Promise<string | null>;
|
|
5
|
+
export {};
|
|
@@ -13,17 +13,17 @@ 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 = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const getComponentSignatureWithPrism = ({ skipSignatureVerify, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
if (!(yield isPrismAvailable())) {
|
|
18
|
-
console.log("Prism must be installed");
|
|
18
|
+
console.log("Prism must be installed.");
|
|
19
19
|
process.exit(1);
|
|
20
20
|
}
|
|
21
|
-
const { stdout } = yield exec(
|
|
21
|
+
const { stdout } = yield exec(`prism components:signature ${skipSignatureVerify ? "--skip-signature-verify" : ""}`, {
|
|
22
22
|
windowsHide: true,
|
|
23
23
|
});
|
|
24
24
|
const signatureKey = stdout.replace(/\n$/, "");
|
|
25
25
|
if (!signatureKey) {
|
|
26
|
-
console.log("Failed to get component signature
|
|
26
|
+
console.log("Failed to get component signature, please verify your component has been published.");
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
29
|
return signatureKey;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
12
|
var t = {};
|
|
4
13
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -27,8 +36,19 @@ const convertIntegration = (definition) => {
|
|
|
27
36
|
// actions, triggers, data sources, and connections that are created
|
|
28
37
|
// inline as part of the integration definition.
|
|
29
38
|
const referenceKey = (0, uuid_1.v4)();
|
|
30
|
-
const configVars = Object.
|
|
31
|
-
|
|
39
|
+
const configVars = Object.values((_a = definition.configPages) !== null && _a !== void 0 ? _a : {}).reduce((acc, configPage) => Object.entries(configPage.elements).reduce((acc, [key, element]) => {
|
|
40
|
+
// "string" elements are HTML elements and should be ignored.
|
|
41
|
+
if (typeof element === "string") {
|
|
42
|
+
return acc;
|
|
43
|
+
}
|
|
44
|
+
if (key in acc) {
|
|
45
|
+
throw new Error('Duplicate config var key "' + key + '"');
|
|
46
|
+
}
|
|
47
|
+
return Object.assign(Object.assign({}, acc), { [key]: element });
|
|
48
|
+
}, acc), {});
|
|
49
|
+
const cniComponent = codeNativeIntegrationComponent(definition, referenceKey, configVars);
|
|
50
|
+
const cniYaml = codeNativeIntegrationYaml(definition, referenceKey, configVars);
|
|
51
|
+
return Object.assign(Object.assign({}, cniComponent), { codeNativeIntegrationYAML: cniYaml });
|
|
32
52
|
};
|
|
33
53
|
exports.convertIntegration = convertIntegration;
|
|
34
54
|
const convertConfigPages = (pages) => {
|
|
@@ -38,10 +58,15 @@ const convertConfigPages = (pages) => {
|
|
|
38
58
|
return Object.entries(pages).map(([name, { tagline, elements }]) => ({
|
|
39
59
|
name,
|
|
40
60
|
tagline,
|
|
41
|
-
elements: Object.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
elements: Object.entries(elements).map(([key, value]) => typeof value === "string"
|
|
62
|
+
? {
|
|
63
|
+
type: "htmlElement",
|
|
64
|
+
value,
|
|
65
|
+
}
|
|
66
|
+
: {
|
|
67
|
+
type: "configVar",
|
|
68
|
+
value: key,
|
|
69
|
+
}),
|
|
45
70
|
}));
|
|
46
71
|
};
|
|
47
72
|
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, componentRegistry = {}, }, referenceKey, configVars) => {
|
|
@@ -89,6 +114,48 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
89
114
|
};
|
|
90
115
|
return yaml_1.default.stringify(result);
|
|
91
116
|
};
|
|
117
|
+
const permissionAndVisibilityTypeValueMap = {
|
|
118
|
+
customer: {
|
|
119
|
+
orgOnly: false,
|
|
120
|
+
visibleToOrgDeployer: true,
|
|
121
|
+
visibleToCustomerDeployer: true,
|
|
122
|
+
},
|
|
123
|
+
embedded: {
|
|
124
|
+
orgOnly: false,
|
|
125
|
+
visibleToOrgDeployer: true,
|
|
126
|
+
visibleToCustomerDeployer: false,
|
|
127
|
+
},
|
|
128
|
+
organization: {
|
|
129
|
+
orgOnly: true,
|
|
130
|
+
visibleToOrgDeployer: true,
|
|
131
|
+
visibleToCustomerDeployer: false,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
const getPermissionAndVisibilityValues = ({ permissionAndVisibilityType = "customer", visibleToOrgDeployer = true, }) => {
|
|
135
|
+
return Object.assign(Object.assign({}, permissionAndVisibilityTypeValueMap[permissionAndVisibilityType]), (visibleToOrgDeployer !== undefined ? { visibleToOrgDeployer } : {}));
|
|
136
|
+
};
|
|
137
|
+
/** Converts permission and visibility properties into `meta` properties for inputs. */
|
|
138
|
+
const convertInputPermissionAndVisibility = ({ permissionAndVisibilityType, visibleToOrgDeployer, }) => {
|
|
139
|
+
const meta = getPermissionAndVisibilityValues({
|
|
140
|
+
permissionAndVisibilityType,
|
|
141
|
+
visibleToOrgDeployer,
|
|
142
|
+
});
|
|
143
|
+
return meta;
|
|
144
|
+
};
|
|
145
|
+
/** Converts permission and visibility properties into `meta` properties for config vars. */
|
|
146
|
+
const convertConfigVarPermissionAndVisibility = ({ permissionAndVisibilityType, visibleToOrgDeployer: visibleToOrgDeployerBase, }) => {
|
|
147
|
+
const { orgOnly, visibleToCustomerDeployer, visibleToOrgDeployer } = getPermissionAndVisibilityValues({
|
|
148
|
+
permissionAndVisibilityType,
|
|
149
|
+
visibleToOrgDeployer: visibleToOrgDeployerBase,
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
orgOnly,
|
|
153
|
+
meta: {
|
|
154
|
+
visibleToCustomerDeployer,
|
|
155
|
+
visibleToOrgDeployer,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
};
|
|
92
159
|
const convertComponentReference = (componentReference, componentRegistry) => {
|
|
93
160
|
var _a, _b, _c;
|
|
94
161
|
const ref = {
|
|
@@ -109,7 +176,11 @@ const convertComponentReference = (componentReference, componentRegistry) => {
|
|
|
109
176
|
value: v,
|
|
110
177
|
}))
|
|
111
178
|
: value.value;
|
|
112
|
-
|
|
179
|
+
const meta = convertInputPermissionAndVisibility((0, lodash_1.pick)(value, [
|
|
180
|
+
"permissionAndVisibilityType",
|
|
181
|
+
"visibleToOrgDeployer",
|
|
182
|
+
]));
|
|
183
|
+
return Object.assign(Object.assign({}, result), { [key]: { type: type, value: valueExpr, meta } });
|
|
113
184
|
}
|
|
114
185
|
if ("configVar" in value) {
|
|
115
186
|
return Object.assign(Object.assign({}, result), { [key]: { type: "configVar", value: value.configVar } });
|
|
@@ -209,15 +280,22 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
209
280
|
};
|
|
210
281
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
211
282
|
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
212
|
-
const meta = (0, lodash_1.pick)(configVar, [
|
|
213
|
-
"visibleToCustomerDeployer",
|
|
214
|
-
"visibleToOrgDeployer",
|
|
215
|
-
]);
|
|
283
|
+
const { orgOnly, meta } = convertConfigVarPermissionAndVisibility((0, lodash_1.pick)(configVar, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
|
|
216
284
|
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
217
|
-
|
|
285
|
+
const { stableKey, description } = (0, lodash_1.pick)(configVar, [
|
|
286
|
+
"stableKey",
|
|
287
|
+
"description",
|
|
288
|
+
]);
|
|
289
|
+
return {
|
|
290
|
+
stableKey,
|
|
291
|
+
description,
|
|
292
|
+
key,
|
|
293
|
+
dataType: "connection",
|
|
294
|
+
connection: {
|
|
218
295
|
key: (0, lodash_1.camelCase)(key),
|
|
219
296
|
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
220
|
-
},
|
|
297
|
+
},
|
|
298
|
+
inputs: Object.entries(configVar.inputs).reduce((result, [key, input]) => {
|
|
221
299
|
if (input.shown === false) {
|
|
222
300
|
return result;
|
|
223
301
|
}
|
|
@@ -226,16 +304,28 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
226
304
|
type: input.collection ? "complex" : "value",
|
|
227
305
|
value: input.default || defaultValue,
|
|
228
306
|
} });
|
|
229
|
-
}, {}),
|
|
307
|
+
}, {}),
|
|
308
|
+
orgOnly,
|
|
309
|
+
meta,
|
|
310
|
+
};
|
|
230
311
|
}
|
|
231
312
|
if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
|
|
232
313
|
const { ref, inputs } = convertComponentReference(configVar.connection, componentRegistry);
|
|
233
|
-
|
|
314
|
+
const { stableKey = "", description, connection: { template }, } = (0, lodash_1.pick)(configVar, ["stableKey", "description", "connection"]);
|
|
315
|
+
return {
|
|
316
|
+
stableKey,
|
|
317
|
+
description,
|
|
318
|
+
key,
|
|
319
|
+
dataType: "connection",
|
|
320
|
+
connection: Object.assign(Object.assign({}, ref), { template }),
|
|
321
|
+
inputs,
|
|
322
|
+
orgOnly,
|
|
323
|
+
meta,
|
|
324
|
+
};
|
|
234
325
|
}
|
|
235
|
-
const result = (0, lodash_1.assign)({ meta, key }, (0, lodash_1.pick)(configVar, [
|
|
326
|
+
const result = (0, lodash_1.assign)({ orgOnly, meta, key }, (0, lodash_1.pick)(configVar, [
|
|
236
327
|
"stableKey",
|
|
237
328
|
"description",
|
|
238
|
-
"orgOnly",
|
|
239
329
|
"defaultValue",
|
|
240
330
|
"dataType",
|
|
241
331
|
"pickList",
|
|
@@ -284,17 +374,44 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
|
|
|
284
374
|
const { _components } = context, remainingContext = __rest(context, ["_components"]);
|
|
285
375
|
const invoke = _components
|
|
286
376
|
.invoke;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
377
|
+
// Construct the component methods from the component registry
|
|
378
|
+
const componentMethods = Object.entries(componentRegistry).reduce((accumulator, [registryComponentKey, { key: componentKey, actions, public: isPublic, signature },]) => {
|
|
379
|
+
// Create an object to hold the methods for each action
|
|
380
|
+
const methods = Object.keys(actions).reduce((methodsAccumulator, actionKey) => {
|
|
381
|
+
const action = actions[actionKey];
|
|
382
|
+
// Define the method to be called for the action
|
|
383
|
+
methodsAccumulator[actionKey] = (values) => __awaiter(void 0, void 0, void 0, function* () {
|
|
384
|
+
// Transform the input values based on the action's inputs
|
|
385
|
+
const transformedValues = Object.entries(values).reduce((transformedAccumulator, [inputKey, inputValue]) => {
|
|
386
|
+
const { collection } = action.inputs[inputKey];
|
|
387
|
+
// Transform key-value list inputs
|
|
388
|
+
if (collection === "keyvaluelist" &&
|
|
389
|
+
Object.keys(inputValue).length) {
|
|
390
|
+
transformedAccumulator[inputKey] = Object.entries(inputValue).map(([keyItem, valueItem]) => ({
|
|
391
|
+
key: keyItem,
|
|
392
|
+
value: valueItem,
|
|
393
|
+
}));
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
transformedAccumulator[inputKey] = inputValue;
|
|
397
|
+
}
|
|
398
|
+
return transformedAccumulator;
|
|
399
|
+
}, {});
|
|
400
|
+
// Invoke the action with the transformed values
|
|
401
|
+
return invoke({
|
|
402
|
+
component: {
|
|
403
|
+
key: componentKey,
|
|
404
|
+
signature: signature !== null && signature !== void 0 ? signature : "",
|
|
405
|
+
isPublic,
|
|
406
|
+
},
|
|
407
|
+
key: actionKey,
|
|
408
|
+
}, context, transformedValues);
|
|
409
|
+
});
|
|
410
|
+
return methodsAccumulator;
|
|
411
|
+
}, {});
|
|
412
|
+
// Add the methods to the accumulator under the registry component key
|
|
413
|
+
accumulator[registryComponentKey] = methods;
|
|
414
|
+
return accumulator;
|
|
298
415
|
}, {});
|
|
299
416
|
return onExecution(Object.assign(Object.assign({}, remainingContext), { components: componentMethods }), params);
|
|
300
417
|
};
|
|
@@ -55,7 +55,11 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
|
55
55
|
executionState: Record<string, unknown>;
|
|
56
56
|
integrationState: Record<string, unknown>;
|
|
57
57
|
configVars: TConfigVars;
|
|
58
|
-
components:
|
|
58
|
+
components: {
|
|
59
|
+
[K in keyof TComponentActions]: {
|
|
60
|
+
[A in keyof TComponentActions[K]]: TComponentActions[K][A]["perform"];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
59
63
|
stepId: string;
|
|
60
64
|
executionId: string;
|
|
61
65
|
webhookUrls: Record<string, string>;
|
|
@@ -16,7 +16,11 @@ export declare type ActionContext<TConfigVars extends ConfigVarResultCollection
|
|
|
16
16
|
/** Key/value collection of config variables of the integration. */
|
|
17
17
|
configVars: TConfigVars;
|
|
18
18
|
/** Available component actions registered in the `componentRegistry`. */
|
|
19
|
-
components:
|
|
19
|
+
components: {
|
|
20
|
+
[K in keyof TComponentActions]: {
|
|
21
|
+
[A in keyof TComponentActions[K]]: TComponentActions[K][A]["perform"];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
20
24
|
/** A unique id that corresponds to the step on the Integration */
|
|
21
25
|
stepId: string;
|
|
22
26
|
/** A unique id that corresponds to the specific execution of the Integration */
|
|
@@ -7,7 +7,31 @@ export interface ComponentManifest {
|
|
|
7
7
|
dataSources: Record<string, ComponentManifestDataSource>;
|
|
8
8
|
connections: Record<string, ComponentManifestConnection>;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export interface ComponentManifestAction {
|
|
11
|
+
perform: (values: any) => Promise<unknown>;
|
|
12
|
+
inputs: Record<string, {
|
|
13
|
+
inputType: string;
|
|
14
|
+
collection: "keyvaluelist" | "valuelist" | null;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export interface ComponentManifestTrigger {
|
|
18
|
+
perform: (values: any) => Promise<unknown>;
|
|
19
|
+
inputs: Record<string, {
|
|
20
|
+
inputType: string;
|
|
21
|
+
collection: "keyvaluelist" | "valuelist" | null;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export interface ComponentManifestDataSource {
|
|
25
|
+
perform: (values: any) => Promise<unknown>;
|
|
26
|
+
inputs: Record<string, {
|
|
27
|
+
inputType: string;
|
|
28
|
+
collection: "keyvaluelist" | "valuelist" | null;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export interface ComponentManifestConnection {
|
|
32
|
+
perform: (values: any) => Promise<unknown>;
|
|
33
|
+
inputs: Record<string, {
|
|
34
|
+
inputType: string;
|
|
35
|
+
collection: "keyvaluelist" | "valuelist" | null;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
@@ -100,18 +100,23 @@ export interface Flow<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
100
100
|
[Key in keyof ComponentRegistry]: ComponentRegistry[Key]["actions"];
|
|
101
101
|
}, false, ActionPerformReturn<false, unknown>>;
|
|
102
102
|
}
|
|
103
|
+
export declare type PermissionAndVisibilityType = "customer" | "embedded" | "organization";
|
|
103
104
|
/** Common attribute shared by all types of Config Vars. */
|
|
104
105
|
declare type BaseConfigVar = {
|
|
105
106
|
/** A unique, unchanging value that is used to maintain identity for the Config Var even if the key changes. */
|
|
106
107
|
stableKey: string;
|
|
107
108
|
/** Optional description for this Config Var. */
|
|
108
109
|
description?: string;
|
|
109
|
-
/**
|
|
110
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Optional value that sets the permission and visibility of the Config Var. @default "customer"
|
|
112
|
+
*
|
|
113
|
+
* "customer" - Customers can view and edit the Config Var.
|
|
114
|
+
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically.
|
|
115
|
+
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization.
|
|
116
|
+
*/
|
|
117
|
+
permissionAndVisibilityType?: PermissionAndVisibilityType;
|
|
111
118
|
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */
|
|
112
119
|
visibleToOrgDeployer?: boolean;
|
|
113
|
-
/** Optional value that specifies whether this Config Var is visible to a Customer deployer. @default true */
|
|
114
|
-
visibleToCustomerDeployer?: boolean;
|
|
115
120
|
/** Optional default value for the Config Var. */
|
|
116
121
|
defaultValue?: string;
|
|
117
122
|
/** Optional list of picklist values if the Config Var is a multi-choice selection value. */
|
|
@@ -145,12 +150,24 @@ export declare type ComponentRegistry = keyof IntegrationDefinitionComponentRegi
|
|
|
145
150
|
} : UnionToIntersection<keyof IntegrationDefinitionComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof IntegrationDefinitionComponentRegistry ? {
|
|
146
151
|
[Key in TComponentKey]: IntegrationDefinitionComponentRegistry[TComponentKey];
|
|
147
152
|
} : never : never>;
|
|
153
|
+
interface ConnectionInputPermissionAndVisibility {
|
|
154
|
+
/**
|
|
155
|
+
* Optional value that sets the permission and visibility of the Config Var. @default "customer"
|
|
156
|
+
*
|
|
157
|
+
* "customer" - Customers can view and edit the Config Var.
|
|
158
|
+
* "embedded" - Customers cannot view or update the Config Var as the value will be set programmatically.
|
|
159
|
+
* "organization" - Customers cannot view or update the Config Var as it will always have a default value or be set by the organization.
|
|
160
|
+
*/
|
|
161
|
+
permissionAndVisibilityType?: PermissionAndVisibilityType;
|
|
162
|
+
/** Optional value that specifies whether this Config Var is visible to an Organization deployer. @default true */
|
|
163
|
+
visibleToOrgDeployer?: boolean;
|
|
164
|
+
}
|
|
148
165
|
declare type ComponentReferenceType = Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections">;
|
|
149
166
|
declare type ComponentReferenceTypeValueMap<TValue, TMap extends Record<ComponentReferenceType, unknown> = {
|
|
150
167
|
actions: ValueExpression<TValue>;
|
|
151
168
|
triggers: ValueExpression<TValue> | ConfigVarExpression;
|
|
152
169
|
dataSources: ValueExpression<TValue> | ConfigVarExpression;
|
|
153
|
-
connections: ValueExpression<TValue> | ConfigVarExpression;
|
|
170
|
+
connections: (ValueExpression<TValue> | ConfigVarExpression) & ConnectionInputPermissionAndVisibility;
|
|
154
171
|
}> = TMap;
|
|
155
172
|
export declare type ComponentReference<TComponentReference extends {
|
|
156
173
|
component: string;
|
|
@@ -179,14 +196,14 @@ export declare const isComponentReference: (ref: unknown) => ref is {
|
|
|
179
196
|
template?: string | undefined;
|
|
180
197
|
};
|
|
181
198
|
declare type ComponentReferencesByType = UnionToIntersection<ComponentReferenceType extends infer TComponentReferenceType ? TComponentReferenceType extends Extract<keyof ComponentManifest, "actions" | "triggers" | "dataSources" | "connections"> ? {
|
|
182
|
-
[Key in TComponentReferenceType]: keyof ComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof ComponentRegistry ? TComponentKey extends string ? TComponentReferenceType extends keyof ComponentRegistry[TComponentKey] ? keyof ComponentRegistry[TComponentKey][TComponentReferenceType] extends infer TComponentPropertyKey ? TComponentPropertyKey extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType] ? TComponentPropertyKey extends string ? ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey] extends (...args: any[]) => any ? Parameters<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]>[0] extends infer TInputs ? ComponentReference<{
|
|
199
|
+
[Key in TComponentReferenceType]: keyof ComponentRegistry extends infer TComponentKey ? TComponentKey extends keyof ComponentRegistry ? TComponentKey extends string ? TComponentReferenceType extends keyof ComponentRegistry[TComponentKey] ? keyof ComponentRegistry[TComponentKey][TComponentReferenceType] extends infer TComponentPropertyKey ? TComponentPropertyKey extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType] ? TComponentPropertyKey extends string ? "perform" extends keyof ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey] ? ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]["perform"] extends (...args: any[]) => any ? Parameters<ComponentRegistry[TComponentKey][TComponentReferenceType][TComponentPropertyKey]["perform"]>[0] extends infer TInputs ? ComponentReference<{
|
|
183
200
|
component: TComponentKey;
|
|
184
201
|
isPublic: ComponentRegistry[TComponentKey]["public"];
|
|
185
202
|
key: TComponentPropertyKey;
|
|
186
203
|
values: {
|
|
187
204
|
[Key in keyof TInputs]: ComponentReferenceTypeValueMap<TInputs[Key]>[TComponentReferenceType];
|
|
188
205
|
};
|
|
189
|
-
}> : never : never : never : never : never : never : never : never : never;
|
|
206
|
+
}> : never : never : never : never : never : never : never : never : never : never;
|
|
190
207
|
} : never : never>;
|
|
191
208
|
export declare type TriggerReference = ComponentReferencesByType["triggers"];
|
|
192
209
|
export declare type ActionReference = ComponentReferencesByType["actions"];
|
package/package.json
CHANGED
/package/dist/generators/componentManifest/templates/partials/{inputTypes.ejs → performArgs.ejs}
RENAMED
|
File without changes
|