@prismatic-io/prism 3.3.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run +9 -8
- package/lib/auth.js +183 -201
- package/lib/commands/alerts/events/list.js +27 -57
- package/lib/commands/alerts/groups/create.js +18 -49
- package/lib/commands/alerts/groups/delete.js +10 -41
- package/lib/commands/alerts/groups/list.js +15 -47
- package/lib/commands/alerts/monitors/clear.js +10 -41
- package/lib/commands/alerts/monitors/create.js +27 -58
- package/lib/commands/alerts/monitors/delete.js +10 -41
- package/lib/commands/alerts/monitors/list.js +16 -48
- package/lib/commands/alerts/triggers/list.js +15 -47
- package/lib/commands/alerts/webhooks/create.js +18 -49
- package/lib/commands/alerts/webhooks/delete.js +10 -41
- package/lib/commands/alerts/webhooks/list.js +25 -57
- package/lib/commands/authorization-methods/list.js +20 -51
- package/lib/commands/components/actions/list.js +29 -61
- package/lib/commands/components/delete.js +10 -41
- package/lib/commands/components/dev/run.js +89 -0
- package/lib/commands/components/dev/test.js +218 -0
- package/lib/commands/components/init/action.js +12 -0
- package/lib/commands/components/init/component.js +12 -0
- package/lib/commands/components/init/connection.js +12 -0
- package/lib/commands/components/init/index.js +142 -0
- package/lib/commands/components/init/trigger.js +12 -0
- package/lib/commands/components/list.js +31 -60
- package/lib/commands/components/publish.js +29 -279
- package/lib/commands/components/triggers/list.js +29 -61
- package/lib/commands/customers/create.js +14 -45
- package/lib/commands/customers/credentials/create.js +19 -50
- package/lib/commands/customers/credentials/delete.js +10 -41
- package/lib/commands/customers/credentials/list.js +30 -59
- package/lib/commands/customers/credentials/update.js +16 -47
- package/lib/commands/customers/delete.js +10 -41
- package/lib/commands/customers/list.js +16 -48
- package/lib/commands/customers/update.js +15 -46
- package/lib/commands/customers/users/create.js +18 -49
- package/lib/commands/customers/users/delete.js +10 -41
- package/lib/commands/customers/users/list.js +21 -51
- package/lib/commands/customers/users/roles.js +18 -48
- package/lib/commands/customers/users/update.js +19 -50
- package/lib/commands/executions/step-result/get.js +36 -66
- package/lib/commands/instances/config-vars/list.js +32 -62
- package/lib/commands/instances/create.js +20 -51
- package/lib/commands/instances/delete.js +10 -41
- package/lib/commands/instances/deploy.js +20 -44
- package/lib/commands/instances/disable.js +11 -42
- package/lib/commands/instances/enable.js +11 -42
- package/lib/commands/instances/flow-configs/list.js +25 -55
- package/lib/commands/instances/flow-configs/test.js +62 -97
- package/lib/commands/instances/list.js +31 -59
- package/lib/commands/instances/update.js +15 -46
- package/lib/commands/integrations/available.js +13 -44
- package/lib/commands/integrations/create.js +14 -45
- package/lib/commands/integrations/delete.js +10 -41
- package/lib/commands/integrations/export.js +11 -68
- package/lib/commands/integrations/flows/list.js +22 -52
- package/lib/commands/integrations/flows/test.js +62 -96
- package/lib/commands/integrations/fork.js +15 -46
- package/lib/commands/integrations/import.js +12 -63
- package/lib/commands/integrations/list.js +25 -54
- package/lib/commands/integrations/publish.js +13 -44
- package/lib/commands/integrations/update.js +18 -49
- package/lib/commands/integrations/versions/index.js +26 -58
- package/lib/commands/login.js +16 -32
- package/lib/commands/logout.js +10 -22
- package/lib/commands/logs/severities/list.js +15 -47
- package/lib/commands/me/index.js +15 -60
- package/lib/commands/me/token/revoke.js +12 -0
- package/lib/commands/me/token.js +10 -22
- package/lib/commands/organization/credentials/create.js +17 -48
- package/lib/commands/organization/credentials/delete.js +10 -41
- package/lib/commands/organization/credentials/list.js +22 -54
- package/lib/commands/organization/credentials/update.js +16 -47
- package/lib/commands/organization/update.js +12 -43
- package/lib/commands/organization/updateAvatarUrl.js +14 -45
- package/lib/commands/organization/users/create.js +16 -47
- package/lib/commands/organization/users/delete.js +10 -41
- package/lib/commands/organization/users/list.js +16 -48
- package/lib/commands/organization/users/roles.js +18 -48
- package/lib/commands/organization/users/update.js +19 -50
- package/lib/config.js +24 -30
- package/lib/errors.js +48 -27
- package/lib/fields.js +6 -4
- package/lib/fs.js +6 -14
- package/lib/generate/action.js +43 -100
- package/lib/generate/index.js +27 -23
- package/lib/generate/input.js +28 -43
- package/lib/generate/parse.js +18 -76
- package/lib/generate/sourceFile.js +15 -44
- package/lib/generate/util.js +4 -106
- package/lib/graphql.js +37 -65
- package/lib/index.js +3 -3
- package/lib/utils/component/publish.js +219 -0
- package/lib/utils/component/query.js +23 -0
- package/lib/utils/date.js +14 -0
- package/lib/utils/execution/logs.js +86 -0
- package/lib/utils/integration/definition.js +101 -0
- package/lib/utils/integration/export.js +36 -0
- package/lib/utils/integration/import.js +46 -0
- package/lib/utils/integration/invoke.js +64 -0
- package/lib/utils/integration/query.js +59 -0
- package/lib/utils/serialize.js +8 -0
- package/lib/utils/user/query.js +24 -0
- package/lib/yeoman.js +24 -0
- package/oclif.manifest.json +1 -1
- package/package.json +50 -58
- package/lib/auth.js.map +0 -1
- package/lib/commands/alerts/events/list.js.map +0 -1
- package/lib/commands/alerts/groups/create.js.map +0 -1
- package/lib/commands/alerts/groups/delete.js.map +0 -1
- package/lib/commands/alerts/groups/list.js.map +0 -1
- package/lib/commands/alerts/monitors/clear.js.map +0 -1
- package/lib/commands/alerts/monitors/create.js.map +0 -1
- package/lib/commands/alerts/monitors/delete.js.map +0 -1
- package/lib/commands/alerts/monitors/list.js.map +0 -1
- package/lib/commands/alerts/triggers/list.js.map +0 -1
- package/lib/commands/alerts/webhooks/create.js.map +0 -1
- package/lib/commands/alerts/webhooks/delete.js.map +0 -1
- package/lib/commands/alerts/webhooks/list.js.map +0 -1
- package/lib/commands/authorization-methods/list.js.map +0 -1
- package/lib/commands/components/actions/list.js.map +0 -1
- package/lib/commands/components/delete.js.map +0 -1
- package/lib/commands/components/init.js +0 -224
- package/lib/commands/components/init.js.map +0 -1
- package/lib/commands/components/list.js.map +0 -1
- package/lib/commands/components/publish.js.map +0 -1
- package/lib/commands/components/triggers/list.js.map +0 -1
- package/lib/commands/customers/create.js.map +0 -1
- package/lib/commands/customers/credentials/create.js.map +0 -1
- package/lib/commands/customers/credentials/delete.js.map +0 -1
- package/lib/commands/customers/credentials/list.js.map +0 -1
- package/lib/commands/customers/credentials/update.js.map +0 -1
- package/lib/commands/customers/delete.js.map +0 -1
- package/lib/commands/customers/list.js.map +0 -1
- package/lib/commands/customers/update.js.map +0 -1
- package/lib/commands/customers/users/create.js.map +0 -1
- package/lib/commands/customers/users/delete.js.map +0 -1
- package/lib/commands/customers/users/list.js.map +0 -1
- package/lib/commands/customers/users/roles.js.map +0 -1
- package/lib/commands/customers/users/update.js.map +0 -1
- package/lib/commands/executions/step-result/get.js.map +0 -1
- package/lib/commands/instances/config-vars/list.js.map +0 -1
- package/lib/commands/instances/create.js.map +0 -1
- package/lib/commands/instances/delete.js.map +0 -1
- package/lib/commands/instances/deploy.js.map +0 -1
- package/lib/commands/instances/disable.js.map +0 -1
- package/lib/commands/instances/enable.js.map +0 -1
- package/lib/commands/instances/flow-configs/list.js.map +0 -1
- package/lib/commands/instances/flow-configs/test.js.map +0 -1
- package/lib/commands/instances/list.js.map +0 -1
- package/lib/commands/instances/update.js.map +0 -1
- package/lib/commands/integrations/available.js.map +0 -1
- package/lib/commands/integrations/create.js.map +0 -1
- package/lib/commands/integrations/delete.js.map +0 -1
- package/lib/commands/integrations/export.js.map +0 -1
- package/lib/commands/integrations/flows/list.js.map +0 -1
- package/lib/commands/integrations/flows/test.js.map +0 -1
- package/lib/commands/integrations/fork.js.map +0 -1
- package/lib/commands/integrations/import.js.map +0 -1
- package/lib/commands/integrations/list.js.map +0 -1
- package/lib/commands/integrations/publish.js.map +0 -1
- package/lib/commands/integrations/update.js.map +0 -1
- package/lib/commands/integrations/versions/index.js.map +0 -1
- package/lib/commands/login.js.map +0 -1
- package/lib/commands/logout.js.map +0 -1
- package/lib/commands/logs/severities/list.js.map +0 -1
- package/lib/commands/me/index.js.map +0 -1
- package/lib/commands/me/token.js.map +0 -1
- package/lib/commands/organization/credentials/create.js.map +0 -1
- package/lib/commands/organization/credentials/delete.js.map +0 -1
- package/lib/commands/organization/credentials/list.js.map +0 -1
- package/lib/commands/organization/credentials/update.js.map +0 -1
- package/lib/commands/organization/update.js.map +0 -1
- package/lib/commands/organization/updateAvatarUrl.js.map +0 -1
- package/lib/commands/organization/users/create.js.map +0 -1
- package/lib/commands/organization/users/delete.js.map +0 -1
- package/lib/commands/organization/users/list.js.map +0 -1
- package/lib/commands/organization/users/roles.js.map +0 -1
- package/lib/commands/organization/users/update.js.map +0 -1
- package/lib/config.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/fields.js.map +0 -1
- package/lib/fs.js.map +0 -1
- package/lib/generate/action.js.map +0 -1
- package/lib/generate/client.js +0 -98
- package/lib/generate/client.js.map +0 -1
- package/lib/generate/connection.js +0 -86
- package/lib/generate/connection.js.map +0 -1
- package/lib/generate/index.js.map +0 -1
- package/lib/generate/input.js.map +0 -1
- package/lib/generate/parse.js.map +0 -1
- package/lib/generate/sourceFile.js.map +0 -1
- package/lib/generate/util.js.map +0 -1
- package/lib/graphql.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/templates/component/assets/icon.png +0 -0
- package/templates/component/jest.config.js +0 -4
- package/templates/component/openapi/client.ts +0 -73
- package/templates/component/openapi/request.ts +0 -161
- package/templates/component/package.json +0 -24
- package/templates/component/src/actions.ts +0 -33
- package/templates/component/src/client.ts +0 -7
- package/templates/component/src/connections.ts +0 -25
- package/templates/component/src/index.test.ts +0 -32
- package/templates/component/src/index.ts +0 -17
- package/templates/component/src/triggers.ts +0 -18
- package/templates/component/tsconfig.json +0 -19
- package/templates/component/webpack.config.js +0 -44
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const graphql_1 = require("../../../graphql");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const spawnProcess = ([command, ...args], env) => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const child = (0, child_process_1.spawn)(command, args, {
|
|
9
|
+
env: { ...process.env, ...env },
|
|
10
|
+
});
|
|
11
|
+
child.stdout.pipe(process.stdout);
|
|
12
|
+
child.stderr.pipe(process.stderr);
|
|
13
|
+
child.on("close", (code) => (code === 0 ? resolve() : reject()));
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
class RunCommand extends core_1.Command {
|
|
17
|
+
async run() {
|
|
18
|
+
const { argv, flags: { integrationId, connectionKey }, } = await this.parse(RunCommand);
|
|
19
|
+
const result = await (0, graphql_1.gqlRequest)({
|
|
20
|
+
document: (0, graphql_1.gql) `
|
|
21
|
+
query integration($id: ID!) {
|
|
22
|
+
integration(id: $id) {
|
|
23
|
+
testConfigVariables {
|
|
24
|
+
nodes {
|
|
25
|
+
requiredConfigVariable {
|
|
26
|
+
key
|
|
27
|
+
}
|
|
28
|
+
inputs {
|
|
29
|
+
nodes {
|
|
30
|
+
name
|
|
31
|
+
value
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
meta
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
variables: {
|
|
41
|
+
id: integrationId,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const nodes = result.integration.testConfigVariables.nodes;
|
|
45
|
+
const [connection] = nodes.filter(({ requiredConfigVariable: { key } }) => key === connectionKey);
|
|
46
|
+
if (!connection) {
|
|
47
|
+
core_1.CliUx.ux.error("Failed to find active connection.", { exit: 1 });
|
|
48
|
+
}
|
|
49
|
+
const { meta, inputs } = connection;
|
|
50
|
+
const fields = inputs.nodes.reduce((result, { name, value }) => ({ ...result, [name]: value }), {});
|
|
51
|
+
const value = JSON.stringify({
|
|
52
|
+
...JSON.parse(meta),
|
|
53
|
+
fields,
|
|
54
|
+
});
|
|
55
|
+
await spawnProcess(argv, { PRISMATIC_CONNECTION_VALUE: value });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = RunCommand;
|
|
59
|
+
RunCommand.description = `Fetch an integration's active connection and execute a CLI command with that connection's fields as an environment variable.`;
|
|
60
|
+
RunCommand.usage = "prism components:dev:run -i <value> -c <value> -- /command/to/run";
|
|
61
|
+
RunCommand.examples = [
|
|
62
|
+
{
|
|
63
|
+
description: `To simply print an integration's basic auth config variable named "My Credentials" and pipe the resulting JSON to jq, run:`,
|
|
64
|
+
command: `$ prism components:dev:run
|
|
65
|
+
--integrationId SW50ZWdyYXRpb246Y2YyMjJlMWUtMzJiYy00NTNhLWIzOWQtYTliNzUwMDAyNjBk
|
|
66
|
+
--connectionKey "My Credentials" --
|
|
67
|
+
printenv \${PRISMATIC_CONNECTION_VALUE} | jq`,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
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:`,
|
|
71
|
+
command: `$ prism components:dev:run -i SW50ZWexample -c "Slack Connection" -- yarn run test`,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
// Allow us to manually capture argv so we can isolate the wrapped command.
|
|
75
|
+
RunCommand.strict = false;
|
|
76
|
+
// TODO: Make this derive from the component manifest using the same
|
|
77
|
+
// logic as the `test` command.
|
|
78
|
+
RunCommand.flags = {
|
|
79
|
+
integrationId: core_1.Flags.string({
|
|
80
|
+
required: true,
|
|
81
|
+
char: "i",
|
|
82
|
+
description: "Integration ID",
|
|
83
|
+
}),
|
|
84
|
+
connectionKey: core_1.Flags.string({
|
|
85
|
+
required: true,
|
|
86
|
+
char: "c",
|
|
87
|
+
description: "Key of the connection config variable to fetch meta/state for",
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
@@ -0,0 +1,218 @@
|
|
|
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 inquirer_1 = __importDefault(require("inquirer"));
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const publish_1 = require("../../../utils/component/publish");
|
|
12
|
+
const logs_1 = require("../../../utils/execution/logs");
|
|
13
|
+
const definition_1 = require("../../../utils/integration/definition");
|
|
14
|
+
const import_1 = require("../../../utils/integration/import");
|
|
15
|
+
const invoke_1 = require("../../../utils/integration/invoke");
|
|
16
|
+
const query_1 = require("../../../utils/integration/query");
|
|
17
|
+
const fs_1 = require("../../../fs");
|
|
18
|
+
const query_2 = require("../../../utils/user/query");
|
|
19
|
+
const setTimeoutPromise = (0, util_1.promisify)(setTimeout);
|
|
20
|
+
const envVarCase = (name) => (0, lodash_1.upperCase)((0, lodash_1.snakeCase)(name)).replace(/\s+/g, "_");
|
|
21
|
+
const toInquirerInputType = (type, collection) => {
|
|
22
|
+
if (collection) {
|
|
23
|
+
// FIXME: Improve prompting instead of instantly bailing to editor.
|
|
24
|
+
return "editor";
|
|
25
|
+
}
|
|
26
|
+
switch (type) {
|
|
27
|
+
case "boolean":
|
|
28
|
+
return "checkbox";
|
|
29
|
+
case "password":
|
|
30
|
+
return "password";
|
|
31
|
+
case "code":
|
|
32
|
+
return "editor";
|
|
33
|
+
default:
|
|
34
|
+
return "input";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getInputQuestion = ({ key, label, type, collection, default: defaultValue, }) => ({
|
|
38
|
+
type: toInquirerInputType(type, collection),
|
|
39
|
+
name: key,
|
|
40
|
+
message: `${label}:`,
|
|
41
|
+
when: (answers) => {
|
|
42
|
+
var _a;
|
|
43
|
+
const envVar = envVarCase(key);
|
|
44
|
+
const exists = envVar in process.env;
|
|
45
|
+
if (exists) {
|
|
46
|
+
const value = (_a = process.env[envVar]) !== null && _a !== void 0 ? _a : "";
|
|
47
|
+
answers[key] = collection
|
|
48
|
+
? { type: "complex", value: JSON.parse(value) }
|
|
49
|
+
: { type: "value", value };
|
|
50
|
+
}
|
|
51
|
+
return !exists;
|
|
52
|
+
},
|
|
53
|
+
filter: (value) => {
|
|
54
|
+
if (type === "connection") {
|
|
55
|
+
return { type: "configVar", value };
|
|
56
|
+
}
|
|
57
|
+
if (collection) {
|
|
58
|
+
return {
|
|
59
|
+
type: "complex",
|
|
60
|
+
value: JSON.parse(value),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
type: "value",
|
|
65
|
+
value,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
default: () => (type === "connection" ? "testConnection" : defaultValue),
|
|
69
|
+
});
|
|
70
|
+
const valuesFromAnswers = ({ action, actionInputs, connection, connectionInputs = {}, }) => {
|
|
71
|
+
const actionValues = Object.entries(actionInputs).reduce((result, [key, value]) => ({
|
|
72
|
+
...result,
|
|
73
|
+
[key]: value,
|
|
74
|
+
}), {});
|
|
75
|
+
const connectionValues = Object.entries(connectionInputs).reduce((result, [key, value]) => ({
|
|
76
|
+
...result,
|
|
77
|
+
[key]: value,
|
|
78
|
+
}), {});
|
|
79
|
+
const connectionInfo = connection
|
|
80
|
+
? { key: connection.key, values: connectionValues }
|
|
81
|
+
: undefined;
|
|
82
|
+
return {
|
|
83
|
+
actionInfo: { key: action.key, values: actionValues },
|
|
84
|
+
connectionInfo,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
class TestCommand extends core_1.Command {
|
|
88
|
+
async run() {
|
|
89
|
+
const { flags: { envPath }, } = await this.parse(TestCommand);
|
|
90
|
+
if (await (0, fs_1.exists)(envPath)) {
|
|
91
|
+
const { error } = dotenv_1.default.config({ path: envPath });
|
|
92
|
+
if (error) {
|
|
93
|
+
core_1.CliUx.ux.error(`Failed to load specified dotenv file: ${error}`, {
|
|
94
|
+
exit: 1,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
core_1.CliUx.ux.action.start("Validating Component");
|
|
99
|
+
const { name } = await (0, query_2.whoAmI)();
|
|
100
|
+
if (!name) {
|
|
101
|
+
core_1.CliUx.ux.error("Failed to determine the name of the currently logged in user.", {
|
|
102
|
+
exit: 1,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const testingKey = (0, lodash_1.kebabCase)(name);
|
|
106
|
+
const definition = await (0, publish_1.loadEntrypoint)();
|
|
107
|
+
const { key: componentKey, public: isPublic } = definition;
|
|
108
|
+
definition.key = `${componentKey}-${testingKey}-testing`;
|
|
109
|
+
definition.display.label = `${definition.display.label} ${name} Testing`;
|
|
110
|
+
await (0, publish_1.validateDefinition)(definition);
|
|
111
|
+
const packagePath = await (0, publish_1.createComponentPackage)();
|
|
112
|
+
const signatureMatches = await (0, publish_1.checkSignature)(definition, packagePath);
|
|
113
|
+
core_1.CliUx.ux.action.stop();
|
|
114
|
+
if (!signatureMatches) {
|
|
115
|
+
core_1.CliUx.ux.action.start("Publishing Component");
|
|
116
|
+
const { iconUploadUrl, packageUploadUrl, connectionIconUploadUrls } = await (0, publish_1.publishDefinition)(definition);
|
|
117
|
+
const { display: { iconPath }, } = definition;
|
|
118
|
+
await (0, publish_1.uploadFile)(iconPath, iconUploadUrl);
|
|
119
|
+
await (0, publish_1.uploadConnectionIcons)(definition, connectionIconUploadUrls);
|
|
120
|
+
await (0, publish_1.uploadFile)(packagePath, packageUploadUrl);
|
|
121
|
+
core_1.CliUx.ux.action.stop();
|
|
122
|
+
}
|
|
123
|
+
const publishedTimestamp = Date.now();
|
|
124
|
+
const actions = definition.actions || {};
|
|
125
|
+
const { action } = await inquirer_1.default.prompt({
|
|
126
|
+
type: "list",
|
|
127
|
+
name: "action",
|
|
128
|
+
message: "Action:",
|
|
129
|
+
choices: Object.entries(actions).map(([key, { display: { label }, },]) => ({
|
|
130
|
+
name: label,
|
|
131
|
+
value: key,
|
|
132
|
+
short: key,
|
|
133
|
+
})),
|
|
134
|
+
default: Object.keys(actions)[0],
|
|
135
|
+
filter: (value) => actions[value],
|
|
136
|
+
});
|
|
137
|
+
const { inputs } = action;
|
|
138
|
+
// Ask for values of action's inputs
|
|
139
|
+
const actionInputs = await inquirer_1.default.prompt(inputs.map((i) => getInputQuestion(i)));
|
|
140
|
+
const answers = {
|
|
141
|
+
action,
|
|
142
|
+
actionInputs,
|
|
143
|
+
};
|
|
144
|
+
// Ask about Connection to test if there is a connection type input
|
|
145
|
+
const hasConnection = inputs.some(({ type }) => type === "connection");
|
|
146
|
+
if (hasConnection) {
|
|
147
|
+
const connections = definition.connections || [];
|
|
148
|
+
const { connection } = await inquirer_1.default.prompt({
|
|
149
|
+
type: "list",
|
|
150
|
+
name: "connection",
|
|
151
|
+
message: "Connection:",
|
|
152
|
+
choices: connections.map(({ key, label }) => ({
|
|
153
|
+
name: label,
|
|
154
|
+
value: key,
|
|
155
|
+
short: key,
|
|
156
|
+
})),
|
|
157
|
+
default: Object.keys(connections)[0],
|
|
158
|
+
filter: (value) => {
|
|
159
|
+
const [connection] = connections.filter(({ key }) => value === key);
|
|
160
|
+
return connection;
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
// Prompt for connection's inputs
|
|
164
|
+
const { inputs } = connection;
|
|
165
|
+
const connectionInputs = await inquirer_1.default.prompt(inputs
|
|
166
|
+
.filter(({ shown }) => shown === undefined || shown === true)
|
|
167
|
+
.map((i) => getInputQuestion(i)));
|
|
168
|
+
Object.assign(answers, { connection, connectionInputs });
|
|
169
|
+
}
|
|
170
|
+
const { actionInfo, connectionInfo } = valuesFromAnswers(answers);
|
|
171
|
+
core_1.CliUx.ux.action.start("Assembling test integration");
|
|
172
|
+
// FIXME: Wait for version to be available but due to issues we have to do a static wait.
|
|
173
|
+
const wait = 5000 - (Date.now() - publishedTimestamp);
|
|
174
|
+
if (wait > 0) {
|
|
175
|
+
await setTimeoutPromise(wait);
|
|
176
|
+
}
|
|
177
|
+
// Build up YAML
|
|
178
|
+
const harnessYaml = await (0, definition_1.buildComponentTestHarnessIntegration)({
|
|
179
|
+
integrationInfo: {
|
|
180
|
+
name: (0, definition_1.componentTestIntegrationName)(componentKey, name),
|
|
181
|
+
},
|
|
182
|
+
componentInfo: { key: definition.key, isPublic: isPublic !== null && isPublic !== void 0 ? isPublic : false },
|
|
183
|
+
actionInfo,
|
|
184
|
+
connectionInfo,
|
|
185
|
+
});
|
|
186
|
+
core_1.CliUx.ux.action.stop();
|
|
187
|
+
core_1.CliUx.ux.action.start("Updating test Integration");
|
|
188
|
+
const { integrationId, flows: [{ id: flowId }], pendingAuthorizations, } = await (0, import_1.importDefinition)(harnessYaml);
|
|
189
|
+
core_1.CliUx.ux.action.stop();
|
|
190
|
+
// Prompt for user authorization of pending connections
|
|
191
|
+
if (pendingAuthorizations.length > 0) {
|
|
192
|
+
const [{ id, url }] = pendingAuthorizations;
|
|
193
|
+
if (!url) {
|
|
194
|
+
throw new Error("Did not receive a valid URL for authorization. Verify your Connection inputs.");
|
|
195
|
+
}
|
|
196
|
+
core_1.CliUx.ux.url("Authorize URL", url);
|
|
197
|
+
await core_1.CliUx.ux.anykey("Press any key to open your browser and authorize the Connection");
|
|
198
|
+
await core_1.CliUx.ux.open(url);
|
|
199
|
+
core_1.CliUx.ux.action.start("Waiting for Connection authorization");
|
|
200
|
+
await (0, query_1.pollForActiveConfigVarState)(integrationId, id);
|
|
201
|
+
core_1.CliUx.ux.action.stop();
|
|
202
|
+
}
|
|
203
|
+
core_1.CliUx.ux.action.start("Running test Integration");
|
|
204
|
+
const { executionId } = await (0, invoke_1.runIntegrationFlow)({ integrationId, flowId });
|
|
205
|
+
await (0, logs_1.displayLogs)(executionId);
|
|
206
|
+
core_1.CliUx.ux.action.stop();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.default = TestCommand;
|
|
210
|
+
TestCommand.description = "Run a Component in Prismatic by publishing it into a test Integration";
|
|
211
|
+
TestCommand.flags = {
|
|
212
|
+
envPath: core_1.Flags.string({
|
|
213
|
+
required: false,
|
|
214
|
+
default: ".env",
|
|
215
|
+
char: "e",
|
|
216
|
+
description: "Path to dotenv file to load for supplying testing values",
|
|
217
|
+
}),
|
|
218
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
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";
|
|
@@ -0,0 +1,12 @@
|
|
|
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";
|
|
@@ -0,0 +1,12 @@
|
|
|
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";
|
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const core_1 = require("@oclif/core");
|
|
30
|
+
const fs_1 = require("fs");
|
|
31
|
+
const path = __importStar(require("path"));
|
|
32
|
+
const wsdl_tsclient_1 = require("wsdl-tsclient");
|
|
33
|
+
const logger_1 = require("wsdl-tsclient/dist/src/utils/logger");
|
|
34
|
+
const index_1 = require("../../../generate/index");
|
|
35
|
+
const prettier_1 = __importDefault(require("prettier"));
|
|
36
|
+
const glob_promise_1 = __importDefault(require("glob-promise"));
|
|
37
|
+
const yeoman_1 = require("../../../yeoman");
|
|
38
|
+
const componentNameRegex = /^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$/;
|
|
39
|
+
const getFilesToFormat = async (basename) => {
|
|
40
|
+
return await (0, glob_promise_1.default)("**/*.ts", {
|
|
41
|
+
ignore: ["**/node_modules/**"],
|
|
42
|
+
cwd: path.dirname(basename),
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const formatSourceFiles = async (basePath, files) => {
|
|
46
|
+
//format the text of each file
|
|
47
|
+
await Promise.all(files.map(async (filePath) => {
|
|
48
|
+
const formattedFile = prettier_1.default.format(await fs_1.promises.readFile(path.resolve(path.dirname(basePath), filePath), "utf-8"), { parser: "typescript" });
|
|
49
|
+
//write the formatted text to the proper file location
|
|
50
|
+
await fs_1.promises.writeFile(path.resolve(path.dirname(basePath), filePath), formattedFile);
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
class InitializeComponent extends core_1.Command {
|
|
54
|
+
async run() {
|
|
55
|
+
const { args: { name }, flags: { verbose, "wsdl-path": wsdlPath, "open-api-path": openApiPath }, } = await this.parse(InitializeComponent);
|
|
56
|
+
if (!componentNameRegex.test(name)) {
|
|
57
|
+
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(componentNameRegex.source)}`, { exit: 1 });
|
|
58
|
+
}
|
|
59
|
+
if (wsdlPath && !(wsdlPath === null || wsdlPath === void 0 ? void 0 : wsdlPath.includes(".wsdl"))) {
|
|
60
|
+
this.error("If a WSDL is provided it must have an extension of '.wsdl'", {
|
|
61
|
+
exit: 1,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
this.log(`Creating component directory for "${name}"...`);
|
|
65
|
+
await fs_1.promises.mkdir(name);
|
|
66
|
+
const cwd = process.cwd();
|
|
67
|
+
process.chdir(name);
|
|
68
|
+
if (openApiPath) {
|
|
69
|
+
await (0, yeoman_1.runGenerator)("formats", {
|
|
70
|
+
name,
|
|
71
|
+
openapi: openApiPath,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
// Legacy code paths (mostly; keep the component generator call)
|
|
76
|
+
await (0, yeoman_1.runGenerator)("component", process.env.NODE_ENV === "test"
|
|
77
|
+
? {
|
|
78
|
+
name,
|
|
79
|
+
description: "Prism-generated Component",
|
|
80
|
+
connectionType: "basic",
|
|
81
|
+
skipInstall: true,
|
|
82
|
+
}
|
|
83
|
+
: { name, skipInstall: Boolean(wsdlPath) });
|
|
84
|
+
// Need to pop back as the WSDL generator assumes it's a directory up
|
|
85
|
+
process.chdir(cwd);
|
|
86
|
+
if (wsdlPath) {
|
|
87
|
+
if (!verbose) {
|
|
88
|
+
// wsdl-tsclient emits pretty noisy logs that aren't particularly useful
|
|
89
|
+
logger_1.Logger.disabled();
|
|
90
|
+
}
|
|
91
|
+
const wsdlName = path.basename(wsdlPath).split(".wsdl")[0];
|
|
92
|
+
await (0, wsdl_tsclient_1.parseAndGenerate)(wsdlPath, name, {
|
|
93
|
+
caseInsensitiveNames: true,
|
|
94
|
+
});
|
|
95
|
+
await (0, index_1.generate)({
|
|
96
|
+
projectRoot: name,
|
|
97
|
+
projectTemplateName: wsdlName,
|
|
98
|
+
projectTemplatePath: wsdlPath,
|
|
99
|
+
});
|
|
100
|
+
await (0, index_1.updatePackageJson)({
|
|
101
|
+
path: path.resolve(name, "package.json"),
|
|
102
|
+
dependencies: { soap: "0.40.0" },
|
|
103
|
+
});
|
|
104
|
+
const filesToFormat = await getFilesToFormat(name);
|
|
105
|
+
await formatSourceFiles(name, filesToFormat);
|
|
106
|
+
}
|
|
107
|
+
this.log(`
|
|
108
|
+
"${name}" is ready for development.
|
|
109
|
+
To install dependencies, run either "npm install" or "yarn install"
|
|
110
|
+
To test the component, run "npm run test" or "yarn test"
|
|
111
|
+
To build the component, run "npm run build" or "yarn build"
|
|
112
|
+
To publish the component, run "prism components:publish"
|
|
113
|
+
|
|
114
|
+
For documentation on writing custom components, visit https://prismatic.io/docs/custom-components/writing-custom-components/
|
|
115
|
+
`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.default = InitializeComponent;
|
|
120
|
+
InitializeComponent.description = "Initialize a new Component";
|
|
121
|
+
InitializeComponent.flags = {
|
|
122
|
+
"wsdl-path": core_1.Flags.string({
|
|
123
|
+
required: false,
|
|
124
|
+
description: "Path to the WSDL definition file used to generate a Component",
|
|
125
|
+
}),
|
|
126
|
+
"open-api-path": core_1.Flags.string({
|
|
127
|
+
required: false,
|
|
128
|
+
description: "The path to an OpenAPI Specification file (JSON or YAML) used to generate a Component",
|
|
129
|
+
}),
|
|
130
|
+
verbose: core_1.Flags.boolean({
|
|
131
|
+
required: false,
|
|
132
|
+
default: false,
|
|
133
|
+
description: "Output more verbose logging from Component generation",
|
|
134
|
+
}),
|
|
135
|
+
};
|
|
136
|
+
InitializeComponent.args = [
|
|
137
|
+
{
|
|
138
|
+
name: "name",
|
|
139
|
+
required: true,
|
|
140
|
+
description: "Name of the new component to create (alphanumeric characters, hyphens, and underscores)",
|
|
141
|
+
},
|
|
142
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
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,43 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
const
|
|
32
|
-
const graphql_1 =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const result = yield graphql_1.default.query({
|
|
40
|
-
query: graphql_1.gql `
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const graphql_1 = require("../../graphql");
|
|
5
|
+
class ListCommand extends core_1.Command {
|
|
6
|
+
async run() {
|
|
7
|
+
const { flags } = await this.parse(ListCommand);
|
|
8
|
+
const { showAllVersions } = flags;
|
|
9
|
+
const result = await (0, graphql_1.gqlRequest)({
|
|
10
|
+
document: (0, graphql_1.gql) `
|
|
41
11
|
query listComponents($showAllVersions: Boolean) {
|
|
42
12
|
components(allVersions: $showAllVersions) {
|
|
43
13
|
nodes {
|
|
@@ -52,33 +22,34 @@ class ListCommand extends command_1.default {
|
|
|
52
22
|
}
|
|
53
23
|
}
|
|
54
24
|
`,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
cli_ux_1.cli.table(result.data.components.nodes, {
|
|
60
|
-
id: {
|
|
61
|
-
minWidth: 8,
|
|
62
|
-
extended: true,
|
|
63
|
-
},
|
|
64
|
-
key: {
|
|
65
|
-
minWidth: 10,
|
|
66
|
-
extended: true,
|
|
67
|
-
},
|
|
68
|
-
label: {},
|
|
69
|
-
public: {},
|
|
70
|
-
description: {},
|
|
71
|
-
versionNumber: { header: "Version" },
|
|
72
|
-
category: {},
|
|
73
|
-
}, Object.assign({}, flags));
|
|
25
|
+
variables: {
|
|
26
|
+
showAllVersions,
|
|
27
|
+
},
|
|
74
28
|
});
|
|
29
|
+
core_1.CliUx.ux.table(result.components.nodes, {
|
|
30
|
+
id: {
|
|
31
|
+
minWidth: 8,
|
|
32
|
+
extended: true,
|
|
33
|
+
},
|
|
34
|
+
key: {
|
|
35
|
+
minWidth: 10,
|
|
36
|
+
extended: true,
|
|
37
|
+
},
|
|
38
|
+
label: {},
|
|
39
|
+
public: {},
|
|
40
|
+
description: {},
|
|
41
|
+
versionNumber: { header: "Version" },
|
|
42
|
+
category: {},
|
|
43
|
+
}, { ...flags });
|
|
75
44
|
}
|
|
76
45
|
}
|
|
77
46
|
exports.default = ListCommand;
|
|
78
47
|
ListCommand.description = "List available Components";
|
|
79
|
-
ListCommand.flags =
|
|
48
|
+
ListCommand.flags = {
|
|
49
|
+
...core_1.CliUx.ux.table.flags(),
|
|
50
|
+
showAllVersions: core_1.Flags.boolean({
|
|
80
51
|
char: "a",
|
|
81
52
|
required: false,
|
|
82
53
|
description: "If specified this command returns all versions of all components rather than only the latest version",
|
|
83
|
-
})
|
|
84
|
-
|
|
54
|
+
}),
|
|
55
|
+
};
|