@prismatic-io/prism 5.2.11 → 6.0.0-preview1
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/lib/index.js +32973 -5
- package/lib/run.js +365 -0
- package/lib/templates/action/action.ts.ejs +33 -0
- package/lib/templates/component/assets/icon.png.ejs +0 -0
- package/lib/templates/component/jest.config.js.ejs +4 -0
- package/lib/templates/component/package.json.ejs +6 -0
- package/lib/templates/component/src/client.ts.ejs +10 -0
- package/lib/templates/component/src/index.test.ts.ejs +47 -0
- package/lib/templates/component/src/index.ts.ejs +19 -0
- package/lib/templates/component/tsconfig.json.ejs +12 -0
- package/lib/templates/component/webpack.config.js.ejs +36 -0
- package/lib/templates/connection/basic.ts.ejs +25 -0
- package/lib/templates/connection/oauth.ts.ejs +65 -0
- package/lib/templates/dataSource/dataSource.ts.ejs +34 -0
- package/lib/templates/flow/flow.ts.ejs +37 -0
- package/lib/templates/formats/assets/icon.png.ejs +0 -0
- package/lib/templates/formats/jest.config.js.ejs +4 -0
- package/lib/templates/formats/tsconfig.json.ejs +12 -0
- package/lib/templates/formats/webpack.config.js.ejs +36 -0
- package/lib/templates/integration/assets/icon.png.ejs +0 -0
- package/lib/templates/integration/basic.ts.ejs +29 -0
- package/lib/templates/integration/jest.config.js.ejs +4 -0
- package/lib/templates/integration/oauth.ts.ejs +69 -0
- package/lib/templates/integration/package.json.ejs +6 -0
- package/lib/templates/integration/src/client.ts.ejs +10 -0
- package/lib/templates/integration/src/index.test.ts.ejs +18 -0
- package/lib/templates/integration/src/index.ts.ejs +11 -0
- package/lib/templates/integration/tsconfig.json.ejs +12 -0
- package/lib/templates/integration/webpack.config.js.ejs +36 -0
- package/lib/templates/trigger/trigger.ts.ejs +19 -0
- package/oclif.manifest.json +3153 -2451
- package/package.json +56 -60
- package/bin/run +0 -12
- package/lib/auth.js +0 -323
- package/lib/commands/alerts/events/list.js +0 -56
- package/lib/commands/alerts/groups/create.js +0 -58
- package/lib/commands/alerts/groups/delete.js +0 -35
- package/lib/commands/alerts/groups/list.js +0 -44
- package/lib/commands/alerts/monitors/clear.js +0 -35
- package/lib/commands/alerts/monitors/create.js +0 -102
- package/lib/commands/alerts/monitors/delete.js +0 -35
- package/lib/commands/alerts/monitors/list.js +0 -63
- package/lib/commands/alerts/triggers/list.js +0 -31
- package/lib/commands/alerts/webhooks/create.js +0 -67
- package/lib/commands/alerts/webhooks/delete.js +0 -35
- package/lib/commands/alerts/webhooks/list.js +0 -57
- package/lib/commands/components/actions/list.js +0 -96
- package/lib/commands/components/data-sources/list.js +0 -114
- package/lib/commands/components/delete.js +0 -35
- package/lib/commands/components/dev/run.js +0 -83
- package/lib/commands/components/dev/test.js +0 -266
- package/lib/commands/components/init/action.js +0 -12
- package/lib/commands/components/init/component.js +0 -12
- package/lib/commands/components/init/connection.js +0 -12
- package/lib/commands/components/init/dataSource.js +0 -12
- package/lib/commands/components/init/index.js +0 -126
- package/lib/commands/components/init/trigger.js +0 -12
- package/lib/commands/components/list.js +0 -95
- package/lib/commands/components/publish.js +0 -62
- package/lib/commands/components/triggers/list.js +0 -96
- package/lib/commands/customers/create.js +0 -72
- package/lib/commands/customers/credentials/create.js +0 -68
- package/lib/commands/customers/credentials/delete.js +0 -35
- package/lib/commands/customers/credentials/list.js +0 -56
- package/lib/commands/customers/credentials/update.js +0 -58
- package/lib/commands/customers/delete.js +0 -35
- package/lib/commands/customers/list.js +0 -51
- package/lib/commands/customers/update.js +0 -82
- package/lib/commands/customers/users/create.js +0 -67
- package/lib/commands/customers/users/delete.js +0 -35
- package/lib/commands/customers/users/list.js +0 -65
- package/lib/commands/customers/users/roles.js +0 -33
- package/lib/commands/customers/users/update.js +0 -76
- package/lib/commands/executions/step-result/get.js +0 -73
- package/lib/commands/instances/config-vars/list.js +0 -83
- package/lib/commands/instances/create.js +0 -84
- package/lib/commands/instances/delete.js +0 -35
- package/lib/commands/instances/deploy.js +0 -43
- package/lib/commands/instances/disable.js +0 -36
- package/lib/commands/instances/enable.js +0 -36
- package/lib/commands/instances/flow-configs/list.js +0 -62
- package/lib/commands/instances/flow-configs/test.js +0 -127
- package/lib/commands/instances/list.js +0 -86
- package/lib/commands/instances/update.js +0 -99
- package/lib/commands/integrations/available.js +0 -47
- package/lib/commands/integrations/create.js +0 -58
- package/lib/commands/integrations/delete.js +0 -35
- package/lib/commands/integrations/export.js +0 -29
- package/lib/commands/integrations/flows/list.js +0 -61
- package/lib/commands/integrations/flows/test.js +0 -124
- package/lib/commands/integrations/fork.js +0 -56
- package/lib/commands/integrations/import.js +0 -54
- package/lib/commands/integrations/init/flow.js +0 -12
- package/lib/commands/integrations/init/index.js +0 -45
- package/lib/commands/integrations/init/integration.js +0 -12
- package/lib/commands/integrations/list.js +0 -96
- package/lib/commands/integrations/marketplace.js +0 -80
- package/lib/commands/integrations/open.js +0 -18
- package/lib/commands/integrations/publish.js +0 -44
- package/lib/commands/integrations/update.js +0 -75
- package/lib/commands/integrations/versions/index.js +0 -83
- package/lib/commands/login.js +0 -33
- package/lib/commands/logout.js +0 -23
- package/lib/commands/logs/severities/list.js +0 -29
- package/lib/commands/me/index.js +0 -22
- package/lib/commands/me/token/revoke.js +0 -12
- package/lib/commands/me/token.js +0 -25
- package/lib/commands/on-prem-resources/delete.js +0 -35
- package/lib/commands/on-prem-resources/list.js +0 -69
- package/lib/commands/on-prem-resources/registration-jwt.js +0 -81
- package/lib/commands/organization/credentials/create.js +0 -60
- package/lib/commands/organization/credentials/delete.js +0 -35
- package/lib/commands/organization/credentials/list.js +0 -45
- package/lib/commands/organization/credentials/update.js +0 -58
- package/lib/commands/organization/signingkeys/delete.js +0 -35
- package/lib/commands/organization/signingkeys/generate.js +0 -22
- package/lib/commands/organization/signingkeys/import.js +0 -40
- package/lib/commands/organization/signingkeys/list.js +0 -36
- package/lib/commands/organization/update.js +0 -37
- package/lib/commands/organization/updateAvatarUrl.js +0 -47
- package/lib/commands/organization/users/create.js +0 -51
- package/lib/commands/organization/users/delete.js +0 -35
- package/lib/commands/organization/users/list.js +0 -60
- package/lib/commands/organization/users/roles.js +0 -33
- package/lib/commands/organization/users/update.js +0 -66
- package/lib/commands/translations/list.js +0 -35
- package/lib/config.js +0 -39
- package/lib/errors.js +0 -55
- package/lib/fields.js +0 -12
- package/lib/fs.js +0 -23
- package/lib/generate/action.js +0 -208
- package/lib/generate/index.js +0 -54
- package/lib/generate/input.js +0 -93
- package/lib/generate/parse.js +0 -59
- package/lib/generate/sourceFile.js +0 -90
- package/lib/generate/util.js +0 -17
- package/lib/graphql.js +0 -42
- package/lib/queries.graphql.js +0 -43
- package/lib/types.js +0 -6
- package/lib/utils/avatar.js +0 -48
- package/lib/utils/component/deleteByKey.js +0 -36
- package/lib/utils/component/publish.js +0 -247
- package/lib/utils/component/query.js +0 -23
- package/lib/utils/date.js +0 -14
- package/lib/utils/execution/logs.js +0 -86
- package/lib/utils/execution/stepResults.js +0 -87
- package/lib/utils/generate.js +0 -50
- package/lib/utils/import.js +0 -21
- package/lib/utils/integration/definition.js +0 -101
- package/lib/utils/integration/export.js +0 -36
- package/lib/utils/integration/import.js +0 -179
- package/lib/utils/integration/invoke.js +0 -81
- package/lib/utils/integration/open.js +0 -37
- package/lib/utils/integration/query.js +0 -59
- package/lib/utils/process.js +0 -15
- package/lib/utils/serialize.js +0 -8
- package/lib/utils/translations/processDataForTranslations.js +0 -132
- package/lib/utils/user/query.js +0 -26
- package/lib/yeoman.js +0 -27
- /package/{bin → lib}/run.cmd +0 -0
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const graphql_1 = require("../../graphql");
|
|
5
|
-
class DeleteCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { args: { component }, } = await this.parse(DeleteCommand);
|
|
8
|
-
await (0, graphql_1.gqlRequest)({
|
|
9
|
-
document: (0, graphql_1.gql) `
|
|
10
|
-
mutation deleteComponent($id: ID!) {
|
|
11
|
-
deleteComponent(input: { id: $id }) {
|
|
12
|
-
component {
|
|
13
|
-
id
|
|
14
|
-
}
|
|
15
|
-
errors {
|
|
16
|
-
field
|
|
17
|
-
messages
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
`,
|
|
22
|
-
variables: {
|
|
23
|
-
id: component,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.default = DeleteCommand;
|
|
29
|
-
DeleteCommand.description = "Delete a Component";
|
|
30
|
-
DeleteCommand.args = {
|
|
31
|
-
component: core_1.Args.string({
|
|
32
|
-
required: true,
|
|
33
|
-
description: "ID of the component to delete",
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
|
-
const graphql_1 = require("../../../graphql");
|
|
6
|
-
const process_1 = require("../../../utils/process");
|
|
7
|
-
class RunCommand extends core_1.Command {
|
|
8
|
-
async run() {
|
|
9
|
-
const { argv, flags: { integrationId, connectionKey }, } = await this.parse(RunCommand);
|
|
10
|
-
if ((0, lodash_1.isEmpty)(argv)) {
|
|
11
|
-
this.error("A command to run must be supplied after a double dash (--) delimiter. See examples in this command's help for details.");
|
|
12
|
-
}
|
|
13
|
-
const result = await (0, graphql_1.gqlRequest)({
|
|
14
|
-
document: (0, graphql_1.gql) `
|
|
15
|
-
query integration($id: ID!) {
|
|
16
|
-
integration(id: $id) {
|
|
17
|
-
testConfigVariables {
|
|
18
|
-
nodes {
|
|
19
|
-
requiredConfigVariable {
|
|
20
|
-
key
|
|
21
|
-
}
|
|
22
|
-
inputs {
|
|
23
|
-
nodes {
|
|
24
|
-
name
|
|
25
|
-
value
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
meta
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`,
|
|
34
|
-
variables: {
|
|
35
|
-
id: integrationId,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const nodes = result.integration.testConfigVariables.nodes;
|
|
39
|
-
const [connection] = nodes.filter(({ requiredConfigVariable: { key } }) => key === connectionKey);
|
|
40
|
-
if (!connection) {
|
|
41
|
-
core_1.ux.error("Failed to find active connection.", { exit: 1 });
|
|
42
|
-
}
|
|
43
|
-
const { meta, inputs } = connection;
|
|
44
|
-
const fields = inputs.nodes.reduce((result, { name, value }) => ({ ...result, [name]: value }), {});
|
|
45
|
-
const value = JSON.stringify({
|
|
46
|
-
...JSON.parse(meta),
|
|
47
|
-
fields,
|
|
48
|
-
});
|
|
49
|
-
await (0, process_1.spawnProcess)(argv, { PRISMATIC_CONNECTION_VALUE: value });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.default = RunCommand;
|
|
53
|
-
RunCommand.description = `Fetch an integration's active connection and execute a CLI command with that connection's fields as an environment variable.`;
|
|
54
|
-
RunCommand.usage = "components:dev:run -i <value> -c <value> -- /command/to/run";
|
|
55
|
-
RunCommand.examples = [
|
|
56
|
-
{
|
|
57
|
-
description: `To simply print an integration's basic auth config variable named "My Credentials" and pipe the resulting JSON to jq, run:`,
|
|
58
|
-
command: `$ prism components:dev:run
|
|
59
|
-
--integrationId SW50ZWexample
|
|
60
|
-
--connectionKey "My Connection" --
|
|
61
|
-
printenv PRISMATIC_CONNECTION_VALUE | jq`,
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
description: `If one of your integrations has an authenticated OAuth 2.0 config variable "Slack Connection", you could run your component's unit tests with that environment variable:`,
|
|
65
|
-
command: `$ prism components:dev:run -i SW50ZWexample -c "Slack Connection" -- yarn run test`,
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
|
-
RunCommand.strict = false; // Manual capture of argv so we can get the wrapped command
|
|
69
|
-
RunCommand["--"] = true; // Stop parsing flags if -- is encountered as an arg
|
|
70
|
-
// TODO: Make this derive from the component manifest using the same
|
|
71
|
-
// logic as the `test` command.
|
|
72
|
-
RunCommand.flags = {
|
|
73
|
-
integrationId: core_1.Flags.string({
|
|
74
|
-
required: true,
|
|
75
|
-
char: "i",
|
|
76
|
-
description: "Integration ID",
|
|
77
|
-
}),
|
|
78
|
-
connectionKey: core_1.Flags.string({
|
|
79
|
-
required: true,
|
|
80
|
-
char: "c",
|
|
81
|
-
description: "Key of the connection config variable to fetch meta/state for",
|
|
82
|
-
}),
|
|
83
|
-
};
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const util_1 = require("util");
|
|
7
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
-
const core_1 = require("@oclif/core");
|
|
9
|
-
const open_1 = __importDefault(require("open"));
|
|
10
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
|
-
const lodash_1 = require("lodash");
|
|
12
|
-
const publish_1 = require("../../../utils/component/publish");
|
|
13
|
-
const logs_1 = require("../../../utils/execution/logs");
|
|
14
|
-
const definition_1 = require("../../../utils/integration/definition");
|
|
15
|
-
const import_1 = require("../../../utils/integration/import");
|
|
16
|
-
const invoke_1 = require("../../../utils/integration/invoke");
|
|
17
|
-
const query_1 = require("../../../utils/integration/query");
|
|
18
|
-
const fs_1 = require("../../../fs");
|
|
19
|
-
const query_2 = require("../../../utils/user/query");
|
|
20
|
-
const process_1 = require("../../../utils/process");
|
|
21
|
-
const stepResults_1 = require("../../../utils/execution/stepResults");
|
|
22
|
-
const deleteByKey_1 = require("../../../utils/component/deleteByKey");
|
|
23
|
-
const setTimeoutPromise = (0, util_1.promisify)(setTimeout);
|
|
24
|
-
const envVarCase = (name) => (0, lodash_1.upperCase)((0, lodash_1.snakeCase)(name)).replace(/\s+/g, "_");
|
|
25
|
-
const toInquirerInputType = (type, collection) => {
|
|
26
|
-
if (collection) {
|
|
27
|
-
// FIXME: Improve prompting instead of instantly bailing to editor.
|
|
28
|
-
return "editor";
|
|
29
|
-
}
|
|
30
|
-
switch (type) {
|
|
31
|
-
case "boolean":
|
|
32
|
-
return "checkbox";
|
|
33
|
-
case "password":
|
|
34
|
-
return "password";
|
|
35
|
-
case "code":
|
|
36
|
-
return "editor";
|
|
37
|
-
default:
|
|
38
|
-
return "input";
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const getInputQuestion = ({ key, label, type, collection, default: defaultValue, }) => ({
|
|
42
|
-
type: toInquirerInputType(type, collection),
|
|
43
|
-
name: key,
|
|
44
|
-
message: `${label}:`,
|
|
45
|
-
when: (answers) => {
|
|
46
|
-
var _a;
|
|
47
|
-
const envVar = envVarCase(key);
|
|
48
|
-
const exists = envVar in process.env;
|
|
49
|
-
if (exists) {
|
|
50
|
-
const value = (_a = process.env[envVar]) !== null && _a !== void 0 ? _a : "";
|
|
51
|
-
answers[key] = collection
|
|
52
|
-
? { type: "complex", value: JSON.parse(value) }
|
|
53
|
-
: { type: "value", value };
|
|
54
|
-
}
|
|
55
|
-
return !exists;
|
|
56
|
-
},
|
|
57
|
-
filter: (value) => {
|
|
58
|
-
if (type === "connection") {
|
|
59
|
-
return { type: "configVar", value };
|
|
60
|
-
}
|
|
61
|
-
if (collection) {
|
|
62
|
-
return {
|
|
63
|
-
type: "complex",
|
|
64
|
-
value: JSON.parse(value),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
type: "value",
|
|
69
|
-
value,
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
default: () => (type === "connection" ? "testConnection" : defaultValue),
|
|
73
|
-
});
|
|
74
|
-
const valuesFromAnswers = ({ action, actionInputs, connection, connectionInputs = {}, }) => {
|
|
75
|
-
const actionValues = Object.entries(actionInputs).reduce((result, [key, value]) => ({
|
|
76
|
-
...result,
|
|
77
|
-
[key]: value,
|
|
78
|
-
}), {});
|
|
79
|
-
const connectionValues = Object.entries(connectionInputs).reduce((result, [key, value]) => ({
|
|
80
|
-
...result,
|
|
81
|
-
[key]: value,
|
|
82
|
-
}), {});
|
|
83
|
-
const connectionInfo = connection
|
|
84
|
-
? { key: connection.key, values: connectionValues }
|
|
85
|
-
: undefined;
|
|
86
|
-
return {
|
|
87
|
-
actionInfo: { key: action.key, values: actionValues },
|
|
88
|
-
connectionInfo,
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
class TestCommand extends core_1.Command {
|
|
92
|
-
async run() {
|
|
93
|
-
const { flags: { envPath, build, "output-file": outputFile, "print-results": printResults, "clean-up": cleanUp, }, } = await this.parse(TestCommand);
|
|
94
|
-
// Save the current working directory, so we can return later after moving to dist/
|
|
95
|
-
const cwd = process.cwd();
|
|
96
|
-
if (build) {
|
|
97
|
-
console.log("Building component...");
|
|
98
|
-
await (0, process_1.spawnProcess)(["npm", "run", "build"], {});
|
|
99
|
-
}
|
|
100
|
-
if (await (0, fs_1.exists)(envPath)) {
|
|
101
|
-
const { error } = dotenv_1.default.config({ path: envPath, override: true });
|
|
102
|
-
if (error) {
|
|
103
|
-
core_1.ux.error(`Failed to load specified dotenv file: ${error}`, {
|
|
104
|
-
exit: 1,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
core_1.ux.action.start("Validating Component");
|
|
109
|
-
const { name } = await (0, query_2.whoAmI)();
|
|
110
|
-
if (!name) {
|
|
111
|
-
core_1.ux.error("Failed to determine the name of the currently logged in user.", {
|
|
112
|
-
exit: 1,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
const testingKey = (0, lodash_1.kebabCase)(name);
|
|
116
|
-
const definition = await (0, publish_1.loadEntrypoint)();
|
|
117
|
-
const { key: componentKey, public: isPublic } = definition;
|
|
118
|
-
definition.key = `${componentKey}-${testingKey}-testing`;
|
|
119
|
-
definition.display.label = `${definition.display.label} ${name} Testing`;
|
|
120
|
-
await (0, publish_1.validateDefinition)(definition);
|
|
121
|
-
const packagePath = await (0, publish_1.createComponentPackage)();
|
|
122
|
-
const signatureMatches = await (0, publish_1.checkPackageSignature)(definition, packagePath);
|
|
123
|
-
core_1.ux.action.stop();
|
|
124
|
-
if (!signatureMatches) {
|
|
125
|
-
core_1.ux.action.start("Publishing Component");
|
|
126
|
-
const { iconUploadUrl, packageUploadUrl, connectionIconUploadUrls } = await (0, publish_1.publishDefinition)(definition);
|
|
127
|
-
const { display: { iconPath }, } = definition;
|
|
128
|
-
await (0, publish_1.uploadFile)(iconPath, iconUploadUrl);
|
|
129
|
-
await (0, publish_1.uploadConnectionIcons)(definition, connectionIconUploadUrls);
|
|
130
|
-
await (0, publish_1.uploadFile)(packagePath, packageUploadUrl);
|
|
131
|
-
core_1.ux.action.stop();
|
|
132
|
-
}
|
|
133
|
-
const publishedTimestamp = Date.now();
|
|
134
|
-
const actions = definition.actions || {};
|
|
135
|
-
const { action } = await inquirer_1.default.prompt({
|
|
136
|
-
type: "list",
|
|
137
|
-
name: "action",
|
|
138
|
-
message: "Action:",
|
|
139
|
-
choices: Object.entries(actions).map(([key, { display: { label }, },]) => ({
|
|
140
|
-
name: label,
|
|
141
|
-
value: key,
|
|
142
|
-
short: key,
|
|
143
|
-
})),
|
|
144
|
-
default: Object.keys(actions)[0],
|
|
145
|
-
filter: (value) => actions[value],
|
|
146
|
-
});
|
|
147
|
-
const { inputs } = action;
|
|
148
|
-
// Ask for values of action's inputs
|
|
149
|
-
const actionInputs = await inquirer_1.default.prompt(inputs.map((i) => getInputQuestion(i)));
|
|
150
|
-
const answers = {
|
|
151
|
-
action,
|
|
152
|
-
actionInputs,
|
|
153
|
-
};
|
|
154
|
-
// Ask about Connection to test if there is a connection type input
|
|
155
|
-
const hasConnection = inputs.some(({ type }) => type === "connection");
|
|
156
|
-
if (hasConnection) {
|
|
157
|
-
const connections = definition.connections || [];
|
|
158
|
-
const { connection } = await inquirer_1.default.prompt({
|
|
159
|
-
type: "list",
|
|
160
|
-
name: "connection",
|
|
161
|
-
message: "Connection:",
|
|
162
|
-
choices: connections.map(({ key, label }) => ({
|
|
163
|
-
name: label,
|
|
164
|
-
value: key,
|
|
165
|
-
short: key,
|
|
166
|
-
})),
|
|
167
|
-
default: Object.keys(connections)[0],
|
|
168
|
-
filter: (value) => {
|
|
169
|
-
const [connection] = connections.filter(({ key }) => value === key);
|
|
170
|
-
return connection;
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
// Prompt for connection's inputs
|
|
174
|
-
const { inputs } = connection;
|
|
175
|
-
const connectionInputs = await inquirer_1.default.prompt(inputs
|
|
176
|
-
.filter(({ shown }) => shown === undefined || shown === true)
|
|
177
|
-
.map((i) => getInputQuestion(i)));
|
|
178
|
-
Object.assign(answers, { connection, connectionInputs });
|
|
179
|
-
}
|
|
180
|
-
const { actionInfo, connectionInfo } = valuesFromAnswers(answers);
|
|
181
|
-
core_1.ux.action.start("Assembling test integration");
|
|
182
|
-
// FIXME: Wait for version to be available but due to issues we have to do a static wait.
|
|
183
|
-
const wait = 5000 - (Date.now() - publishedTimestamp);
|
|
184
|
-
if (wait > 0) {
|
|
185
|
-
await setTimeoutPromise(wait);
|
|
186
|
-
}
|
|
187
|
-
// Build up YAML
|
|
188
|
-
const harnessYaml = await (0, definition_1.buildComponentTestHarnessIntegration)({
|
|
189
|
-
integrationInfo: {
|
|
190
|
-
name: (0, definition_1.componentTestIntegrationName)(componentKey, name),
|
|
191
|
-
},
|
|
192
|
-
componentInfo: { key: definition.key, isPublic: isPublic !== null && isPublic !== void 0 ? isPublic : false },
|
|
193
|
-
actionInfo,
|
|
194
|
-
connectionInfo,
|
|
195
|
-
});
|
|
196
|
-
core_1.ux.action.stop();
|
|
197
|
-
core_1.ux.action.start("Updating test Integration");
|
|
198
|
-
const { integrationId, flows: [{ id: flowId }], pendingAuthorizations, } = await (0, import_1.importDefinition)(harnessYaml);
|
|
199
|
-
core_1.ux.action.stop();
|
|
200
|
-
// Prompt for user authorization of pending connections
|
|
201
|
-
if (pendingAuthorizations.length > 0) {
|
|
202
|
-
const [{ id, url }] = pendingAuthorizations;
|
|
203
|
-
if (!url) {
|
|
204
|
-
throw new Error("Did not receive a valid URL for authorization. Verify your Connection inputs.");
|
|
205
|
-
}
|
|
206
|
-
core_1.ux.url("Authorize URL", url);
|
|
207
|
-
await core_1.ux.anykey("Press any key to open your browser and authorize the Connection");
|
|
208
|
-
await (0, open_1.default)(url);
|
|
209
|
-
core_1.ux.action.start("Waiting for Connection authorization");
|
|
210
|
-
await (0, query_1.pollForActiveConfigVarState)(integrationId, id);
|
|
211
|
-
core_1.ux.action.stop();
|
|
212
|
-
}
|
|
213
|
-
core_1.ux.action.start("Running test Integration");
|
|
214
|
-
const { executionId } = await (0, invoke_1.runIntegrationFlow)({ integrationId, flowId });
|
|
215
|
-
await (0, logs_1.displayLogs)(executionId);
|
|
216
|
-
if (outputFile) {
|
|
217
|
-
process.chdir(cwd);
|
|
218
|
-
console.log(`Writing step results to ${outputFile}`);
|
|
219
|
-
await (0, stepResults_1.writeFinalStepResults)(executionId, outputFile);
|
|
220
|
-
}
|
|
221
|
-
if (printResults) {
|
|
222
|
-
await (0, stepResults_1.printFinalStepResults)(executionId);
|
|
223
|
-
}
|
|
224
|
-
if (cleanUp) {
|
|
225
|
-
core_1.ux.action.start(`Cleaning up test Integration (${integrationId})`);
|
|
226
|
-
await (0, invoke_1.deleteIntegration)(integrationId);
|
|
227
|
-
core_1.ux.action.stop();
|
|
228
|
-
core_1.ux.action.start(`Cleaning up test component (${definition.key})`);
|
|
229
|
-
await (0, deleteByKey_1.deleteComponentByKey)(definition.key);
|
|
230
|
-
core_1.ux.action.stop();
|
|
231
|
-
}
|
|
232
|
-
core_1.ux.action.stop();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
exports.default = TestCommand;
|
|
236
|
-
TestCommand.description = "Run an action of a component within a test integration in the integration runner";
|
|
237
|
-
TestCommand.flags = {
|
|
238
|
-
envPath: core_1.Flags.string({
|
|
239
|
-
required: false,
|
|
240
|
-
default: ".env",
|
|
241
|
-
char: "e",
|
|
242
|
-
description: "Path to dotenv file to load for supplying testing values",
|
|
243
|
-
}),
|
|
244
|
-
build: core_1.Flags.boolean({
|
|
245
|
-
required: false,
|
|
246
|
-
default: true,
|
|
247
|
-
allowNo: true,
|
|
248
|
-
char: "b",
|
|
249
|
-
description: "Build the component prior to testing",
|
|
250
|
-
}),
|
|
251
|
-
"output-file": core_1.Flags.string({
|
|
252
|
-
required: false,
|
|
253
|
-
char: "o",
|
|
254
|
-
description: "Output the results of the action to a specified file",
|
|
255
|
-
}),
|
|
256
|
-
"print-results": core_1.Flags.boolean({
|
|
257
|
-
required: false,
|
|
258
|
-
default: false,
|
|
259
|
-
description: "Print the results of the action to stdout",
|
|
260
|
-
}),
|
|
261
|
-
"clean-up": core_1.Flags.boolean({
|
|
262
|
-
required: false,
|
|
263
|
-
default: false,
|
|
264
|
-
description: "Clean up the integration and temporary component after running the action",
|
|
265
|
-
}),
|
|
266
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const yeoman_1 = require("../../../yeoman");
|
|
5
|
-
class GenerateActionCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
await this.parse(GenerateActionCommand);
|
|
8
|
-
await (0, yeoman_1.runGenerator)("action");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = GenerateActionCommand;
|
|
12
|
-
GenerateActionCommand.description = "Initialize a new Action file";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const yeoman_1 = require("../../../yeoman");
|
|
5
|
-
class GenerateComponentCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
await this.parse(GenerateComponentCommand);
|
|
8
|
-
await (0, yeoman_1.runGenerator)("component");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = GenerateComponentCommand;
|
|
12
|
-
GenerateComponentCommand.description = "Initialize a new Component";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const yeoman_1 = require("../../../yeoman");
|
|
5
|
-
class GenerateConnectionCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
await this.parse(GenerateConnectionCommand);
|
|
8
|
-
await (0, yeoman_1.runGenerator)("connection");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = GenerateConnectionCommand;
|
|
12
|
-
GenerateConnectionCommand.description = "Initialize a new Connection file";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const yeoman_1 = require("../../../yeoman");
|
|
5
|
-
class GenerateActionCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
await this.parse(GenerateActionCommand);
|
|
8
|
-
await (0, yeoman_1.runGenerator)("dataSource");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = GenerateActionCommand;
|
|
12
|
-
GenerateActionCommand.description = "Initialize a new Data Source file";
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const core_1 = require("@oclif/core");
|
|
27
|
-
const fs_1 = require("fs");
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const wsdl_tsclient_1 = require("wsdl-tsclient");
|
|
30
|
-
const logger_1 = require("wsdl-tsclient/dist/src/utils/logger");
|
|
31
|
-
const index_1 = require("../../../generate/index");
|
|
32
|
-
const yeoman_1 = require("../../../yeoman");
|
|
33
|
-
const generate_1 = require("../../../utils/generate");
|
|
34
|
-
class InitializeComponent extends core_1.Command {
|
|
35
|
-
async run() {
|
|
36
|
-
const { args: { name }, flags: { verbose, "wsdl-path": rawWsdlPath, "open-api-path": rawOpenApiPath, }, } = await this.parse(InitializeComponent);
|
|
37
|
-
const wsdlPath = rawWsdlPath ? path.resolve(rawWsdlPath) : undefined;
|
|
38
|
-
const openApiPath = rawOpenApiPath
|
|
39
|
-
? path.resolve(rawOpenApiPath)
|
|
40
|
-
: undefined;
|
|
41
|
-
if (!generate_1.VALID_NAME_REGEX.test(name)) {
|
|
42
|
-
this.error(`'${name}' contains invalid characters. Please select a component name that starts and ends with alphanumeric characters, and contains only alphanumeric characters, hyphens, and underscores. See https://regex101.com/?regex=${encodeURIComponent(generate_1.VALID_NAME_REGEX.source)}`, { exit: 1 });
|
|
43
|
-
}
|
|
44
|
-
if (wsdlPath && !(wsdlPath === null || wsdlPath === void 0 ? void 0 : wsdlPath.includes(".wsdl"))) {
|
|
45
|
-
this.error("If a WSDL is provided it must have an extension of '.wsdl'", {
|
|
46
|
-
exit: 1,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
this.log(`Creating component directory for "${name}"...`);
|
|
50
|
-
await fs_1.promises.mkdir(name);
|
|
51
|
-
const cwd = process.cwd();
|
|
52
|
-
process.chdir(name);
|
|
53
|
-
if (openApiPath) {
|
|
54
|
-
await (0, yeoman_1.runGenerator)("formats", {
|
|
55
|
-
name,
|
|
56
|
-
openapi: openApiPath,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Legacy code paths (mostly; keep the component generator call)
|
|
61
|
-
await (0, yeoman_1.runGenerator)("component", process.env.NODE_ENV === "test"
|
|
62
|
-
? {
|
|
63
|
-
name,
|
|
64
|
-
description: "Prism-generated Component",
|
|
65
|
-
connectionType: "basic",
|
|
66
|
-
skipInstall: true,
|
|
67
|
-
}
|
|
68
|
-
: { name, skipInstall: Boolean(wsdlPath) });
|
|
69
|
-
// Need to pop back as the WSDL generator assumes it's a directory up
|
|
70
|
-
process.chdir(cwd);
|
|
71
|
-
if (wsdlPath) {
|
|
72
|
-
if (!verbose) {
|
|
73
|
-
// wsdl-tsclient emits pretty noisy logs that aren't particularly useful
|
|
74
|
-
logger_1.Logger.disabled();
|
|
75
|
-
}
|
|
76
|
-
const wsdlName = path.basename(wsdlPath).split(".wsdl")[0];
|
|
77
|
-
await (0, wsdl_tsclient_1.parseAndGenerate)(wsdlPath, name, {
|
|
78
|
-
caseInsensitiveNames: true,
|
|
79
|
-
});
|
|
80
|
-
await (0, index_1.generate)({
|
|
81
|
-
projectRoot: name,
|
|
82
|
-
projectTemplateName: wsdlName,
|
|
83
|
-
projectTemplatePath: wsdlPath,
|
|
84
|
-
});
|
|
85
|
-
await (0, index_1.updatePackageJson)({
|
|
86
|
-
path: path.resolve(name, "package.json"),
|
|
87
|
-
dependencies: { soap: "0.40.0" },
|
|
88
|
-
});
|
|
89
|
-
const filesToFormat = await (0, generate_1.getFilesToFormat)(name);
|
|
90
|
-
await (0, generate_1.formatSourceFiles)(name, filesToFormat);
|
|
91
|
-
}
|
|
92
|
-
this.log(`
|
|
93
|
-
"${name}" is ready for development.
|
|
94
|
-
To install dependencies, run either "npm install" or "yarn install"
|
|
95
|
-
To test the component, run "npm run test" or "yarn test"
|
|
96
|
-
To build the component, run "npm run build" or "yarn build"
|
|
97
|
-
To publish the component, run "prism components:publish"
|
|
98
|
-
|
|
99
|
-
For documentation on writing custom components, visit https://prismatic.io/docs/custom-components/writing-custom-components/
|
|
100
|
-
`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.default = InitializeComponent;
|
|
105
|
-
InitializeComponent.description = "Initialize a new Component";
|
|
106
|
-
InitializeComponent.flags = {
|
|
107
|
-
"wsdl-path": core_1.Flags.string({
|
|
108
|
-
required: false,
|
|
109
|
-
description: "Path to the WSDL definition file used to generate a Component",
|
|
110
|
-
}),
|
|
111
|
-
"open-api-path": core_1.Flags.string({
|
|
112
|
-
required: false,
|
|
113
|
-
description: "The path to an OpenAPI Specification file (JSON or YAML) used to generate a Component",
|
|
114
|
-
}),
|
|
115
|
-
verbose: core_1.Flags.boolean({
|
|
116
|
-
required: false,
|
|
117
|
-
default: false,
|
|
118
|
-
description: "Output more verbose logging from Component generation",
|
|
119
|
-
}),
|
|
120
|
-
};
|
|
121
|
-
InitializeComponent.args = {
|
|
122
|
-
name: core_1.Args.string({
|
|
123
|
-
required: true,
|
|
124
|
-
description: "Name of the new component to create (alphanumeric characters, hyphens, and underscores)",
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const yeoman_1 = require("../../../yeoman");
|
|
5
|
-
class GenerateTriggerCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
await this.parse(GenerateTriggerCommand);
|
|
8
|
-
await (0, yeoman_1.runGenerator)("trigger");
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.default = GenerateTriggerCommand;
|
|
12
|
-
GenerateTriggerCommand.description = "Initialize a new Trigger file";
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const core_1 = require("@oclif/core");
|
|
7
|
-
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
|
-
const graphql_1 = require("../../graphql");
|
|
9
|
-
class ListCommand extends core_1.Command {
|
|
10
|
-
async run() {
|
|
11
|
-
const { flags } = await this.parse(ListCommand);
|
|
12
|
-
const { showAllVersions } = flags;
|
|
13
|
-
let components = [];
|
|
14
|
-
let hasNextPage = true;
|
|
15
|
-
let cursor = "";
|
|
16
|
-
while (hasNextPage) {
|
|
17
|
-
const { components: { nodes, pageInfo }, } = await (0, graphql_1.gqlRequest)({
|
|
18
|
-
document: (0, graphql_1.gql) `
|
|
19
|
-
query listComponents($showAllVersions: Boolean, $after: String) {
|
|
20
|
-
components(allVersions: $showAllVersions, after: $after) {
|
|
21
|
-
nodes {
|
|
22
|
-
id
|
|
23
|
-
key
|
|
24
|
-
public
|
|
25
|
-
label
|
|
26
|
-
description
|
|
27
|
-
versionNumber
|
|
28
|
-
category
|
|
29
|
-
versionCreatedAt
|
|
30
|
-
customer {
|
|
31
|
-
id
|
|
32
|
-
externalId
|
|
33
|
-
name
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
pageInfo {
|
|
37
|
-
hasNextPage
|
|
38
|
-
endCursor
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
variables: {
|
|
44
|
-
showAllVersions,
|
|
45
|
-
after: cursor,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
components = [...components, ...nodes];
|
|
49
|
-
cursor = pageInfo.endCursor;
|
|
50
|
-
hasNextPage = pageInfo.hasNextPage;
|
|
51
|
-
}
|
|
52
|
-
core_1.ux.table(components, {
|
|
53
|
-
id: {
|
|
54
|
-
minWidth: 8,
|
|
55
|
-
extended: true,
|
|
56
|
-
},
|
|
57
|
-
key: {
|
|
58
|
-
minWidth: 10,
|
|
59
|
-
extended: true,
|
|
60
|
-
},
|
|
61
|
-
label: {},
|
|
62
|
-
public: {},
|
|
63
|
-
description: {},
|
|
64
|
-
versionNumber: { header: "Version" },
|
|
65
|
-
versionCreatedAt: {
|
|
66
|
-
header: "Last Published",
|
|
67
|
-
extended: true,
|
|
68
|
-
get: ({ versionCreatedAt }) => (0, dayjs_1.default)(versionCreatedAt).format(),
|
|
69
|
-
},
|
|
70
|
-
category: { get: ({ category }) => category || "" },
|
|
71
|
-
customerId: {
|
|
72
|
-
extended: true,
|
|
73
|
-
get: ({ customer }) => { var _a; return (_a = customer === null || customer === void 0 ? void 0 : customer.id) !== null && _a !== void 0 ? _a : ""; },
|
|
74
|
-
},
|
|
75
|
-
customerName: {
|
|
76
|
-
extended: true,
|
|
77
|
-
get: ({ customer }) => { var _a; return (_a = customer === null || customer === void 0 ? void 0 : customer.name) !== null && _a !== void 0 ? _a : ""; },
|
|
78
|
-
},
|
|
79
|
-
customerExternalId: {
|
|
80
|
-
extended: true,
|
|
81
|
-
get: ({ customer }) => { var _a; return (_a = customer === null || customer === void 0 ? void 0 : customer.externalId) !== null && _a !== void 0 ? _a : ""; },
|
|
82
|
-
},
|
|
83
|
-
}, { ...flags });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.default = ListCommand;
|
|
87
|
-
ListCommand.description = "List available Components";
|
|
88
|
-
ListCommand.flags = {
|
|
89
|
-
...core_1.ux.table.flags(),
|
|
90
|
-
showAllVersions: core_1.Flags.boolean({
|
|
91
|
-
char: "a",
|
|
92
|
-
required: false,
|
|
93
|
-
description: "If specified this command returns all versions of all components rather than only the latest version",
|
|
94
|
-
}),
|
|
95
|
-
};
|