@prismatic-io/prism 5.2.10 → 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,51 +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 CreateCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { flags: { name, email, role }, } = await this.parse(CreateCommand);
|
|
8
|
-
const result = await (0, graphql_1.gqlRequest)({
|
|
9
|
-
document: (0, graphql_1.gql) `
|
|
10
|
-
mutation createOrganizationUser(
|
|
11
|
-
$name: String
|
|
12
|
-
$email: String!
|
|
13
|
-
$role: ID!
|
|
14
|
-
) {
|
|
15
|
-
createOrganizationUser(
|
|
16
|
-
input: { name: $name, email: $email, role: $role }
|
|
17
|
-
) {
|
|
18
|
-
user {
|
|
19
|
-
id
|
|
20
|
-
}
|
|
21
|
-
errors {
|
|
22
|
-
field
|
|
23
|
-
messages
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
`,
|
|
28
|
-
variables: {
|
|
29
|
-
name,
|
|
30
|
-
email,
|
|
31
|
-
role,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
this.log(result.createOrganizationUser.user.id);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.default = CreateCommand;
|
|
38
|
-
CreateCommand.description = "Create a User for your Organization";
|
|
39
|
-
CreateCommand.flags = {
|
|
40
|
-
name: core_1.Flags.string({ char: "n", description: "name of the user" }),
|
|
41
|
-
email: core_1.Flags.string({
|
|
42
|
-
char: "e",
|
|
43
|
-
required: true,
|
|
44
|
-
description: "email address of the user",
|
|
45
|
-
}),
|
|
46
|
-
role: core_1.Flags.string({
|
|
47
|
-
char: "r",
|
|
48
|
-
required: true,
|
|
49
|
-
description: "role the user should assume",
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
@@ -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: { user }, } = await this.parse(DeleteCommand);
|
|
8
|
-
await (0, graphql_1.gqlRequest)({
|
|
9
|
-
document: (0, graphql_1.gql) `
|
|
10
|
-
mutation deleteUser($id: ID!) {
|
|
11
|
-
deleteUser(input: { id: $id }) {
|
|
12
|
-
user {
|
|
13
|
-
id
|
|
14
|
-
}
|
|
15
|
-
errors {
|
|
16
|
-
field
|
|
17
|
-
messages
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
`,
|
|
22
|
-
variables: {
|
|
23
|
-
id: user,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.default = DeleteCommand;
|
|
29
|
-
DeleteCommand.description = "Delete an Organization User";
|
|
30
|
-
DeleteCommand.args = {
|
|
31
|
-
user: core_1.Args.string({
|
|
32
|
-
required: true,
|
|
33
|
-
description: "ID of the user to delete",
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
@@ -1,60 +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 ListCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { flags } = await this.parse(ListCommand);
|
|
8
|
-
let customerUsers = [];
|
|
9
|
-
let hasNextPage = true;
|
|
10
|
-
let cursor = "";
|
|
11
|
-
while (hasNextPage) {
|
|
12
|
-
const { organization: { users: { nodes, pageInfo }, }, } = await (0, graphql_1.gqlRequest)({
|
|
13
|
-
document: (0, graphql_1.gql) `
|
|
14
|
-
query listUsers($after: String) {
|
|
15
|
-
organization {
|
|
16
|
-
users(after: $after) {
|
|
17
|
-
nodes {
|
|
18
|
-
id
|
|
19
|
-
name
|
|
20
|
-
email
|
|
21
|
-
externalId
|
|
22
|
-
phone
|
|
23
|
-
role {
|
|
24
|
-
name
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
pageInfo {
|
|
28
|
-
hasNextPage
|
|
29
|
-
endCursor
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`,
|
|
35
|
-
variables: { after: cursor },
|
|
36
|
-
});
|
|
37
|
-
customerUsers = [...customerUsers, ...nodes];
|
|
38
|
-
cursor = pageInfo.endCursor;
|
|
39
|
-
hasNextPage = pageInfo.hasNextPage;
|
|
40
|
-
}
|
|
41
|
-
core_1.ux.table(customerUsers, {
|
|
42
|
-
id: {
|
|
43
|
-
minWidth: 8,
|
|
44
|
-
extended: true,
|
|
45
|
-
},
|
|
46
|
-
name: {},
|
|
47
|
-
email: {},
|
|
48
|
-
phone: {},
|
|
49
|
-
role: {
|
|
50
|
-
get: ({ role }) => role.name,
|
|
51
|
-
},
|
|
52
|
-
externalId: {
|
|
53
|
-
get: ({ externalId }) => externalId || "",
|
|
54
|
-
},
|
|
55
|
-
}, { ...flags });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.default = ListCommand;
|
|
59
|
-
ListCommand.description = "List Users of your Organization";
|
|
60
|
-
ListCommand.flags = { ...core_1.ux.table.flags() };
|
|
@@ -1,33 +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 ListCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { flags } = await this.parse(ListCommand);
|
|
8
|
-
const result = await (0, graphql_1.gqlRequest)({
|
|
9
|
-
document: (0, graphql_1.gql) `
|
|
10
|
-
query listOrganizationRoles {
|
|
11
|
-
organizationRoles {
|
|
12
|
-
id
|
|
13
|
-
name
|
|
14
|
-
description
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
`,
|
|
18
|
-
});
|
|
19
|
-
core_1.ux.table(result.organizationRoles, {
|
|
20
|
-
id: {
|
|
21
|
-
minWidth: 8,
|
|
22
|
-
extended: true,
|
|
23
|
-
},
|
|
24
|
-
name: {},
|
|
25
|
-
description: {},
|
|
26
|
-
}, { ...flags });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.default = ListCommand;
|
|
30
|
-
ListCommand.description = "List Roles you can grant to other users in your Organization";
|
|
31
|
-
ListCommand.flags = {
|
|
32
|
-
...core_1.ux.table.flags(),
|
|
33
|
-
};
|
|
@@ -1,66 +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 UpdateCommand extends core_1.Command {
|
|
6
|
-
async run() {
|
|
7
|
-
const { args: { user }, flags: { name, phone, "dark-mode": darkMode, "dark-mode-os-sync": darkModeOsSync, }, } = await this.parse(UpdateCommand);
|
|
8
|
-
const result = await (0, graphql_1.gqlRequest)({
|
|
9
|
-
document: (0, graphql_1.gql) `
|
|
10
|
-
mutation updateUser(
|
|
11
|
-
$user: ID!
|
|
12
|
-
$name: String
|
|
13
|
-
$phone: String
|
|
14
|
-
$darkMode: Boolean
|
|
15
|
-
$darkModeOsSync: Boolean
|
|
16
|
-
) {
|
|
17
|
-
updateUser(
|
|
18
|
-
input: {
|
|
19
|
-
id: $user
|
|
20
|
-
name: $name
|
|
21
|
-
phone: $phone
|
|
22
|
-
darkMode: $darkMode
|
|
23
|
-
darkModeSyncWithOs: $darkModeOsSync
|
|
24
|
-
}
|
|
25
|
-
) {
|
|
26
|
-
user {
|
|
27
|
-
id
|
|
28
|
-
}
|
|
29
|
-
errors {
|
|
30
|
-
field
|
|
31
|
-
messages
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
`,
|
|
36
|
-
variables: {
|
|
37
|
-
user,
|
|
38
|
-
name,
|
|
39
|
-
phone,
|
|
40
|
-
darkMode,
|
|
41
|
-
darkModeOsSync,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
this.log(result.updateUser.user.id);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = UpdateCommand;
|
|
48
|
-
UpdateCommand.description = "Update a User";
|
|
49
|
-
UpdateCommand.args = {
|
|
50
|
-
user: core_1.Args.string({
|
|
51
|
-
required: true,
|
|
52
|
-
description: "ID of a user",
|
|
53
|
-
}),
|
|
54
|
-
};
|
|
55
|
-
UpdateCommand.flags = {
|
|
56
|
-
name: core_1.Flags.string({ char: "n", description: "name of the user" }),
|
|
57
|
-
phone: core_1.Flags.string({ char: "p", description: "phone number of the user" }),
|
|
58
|
-
"dark-mode": core_1.Flags.string({
|
|
59
|
-
char: "d",
|
|
60
|
-
description: "whether the user should have dark mode enabled",
|
|
61
|
-
}),
|
|
62
|
-
"dark-mode-os-sync": core_1.Flags.string({
|
|
63
|
-
char: "o",
|
|
64
|
-
description: "whether dark mode should sync with OS settings",
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
@@ -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
|
-
const processDataForTranslations_1 = require("../../utils/translations/processDataForTranslations");
|
|
6
|
-
const queries_graphql_1 = require("../../queries.graphql");
|
|
7
|
-
const fs_1 = require("../../fs");
|
|
8
|
-
class TranslationsCommand extends core_1.Command {
|
|
9
|
-
async run() {
|
|
10
|
-
const { flags: { "output-file": output }, } = await this.parse(TranslationsCommand);
|
|
11
|
-
const cwd = process.cwd();
|
|
12
|
-
const result = await (0, graphql_1.gqlRequest)({
|
|
13
|
-
document: queries_graphql_1.GET_MARKETPLACE_INTEGRATIONS_TRANSLATIONS,
|
|
14
|
-
});
|
|
15
|
-
const processedIntegrations = (0, processDataForTranslations_1.processIntegrationsForTranslations)(result);
|
|
16
|
-
if (output) {
|
|
17
|
-
process.chdir(cwd);
|
|
18
|
-
this.log(`Writing translations to ${output}`);
|
|
19
|
-
fs_1.fs.writeFile(output, JSON.stringify(processedIntegrations, null, 2));
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this.logJson(processedIntegrations);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.default = TranslationsCommand;
|
|
27
|
-
TranslationsCommand.description = "Generate Dynamic Phrases for Embedded Marketplace";
|
|
28
|
-
TranslationsCommand.flags = {
|
|
29
|
-
"output-file": core_1.Flags.string({
|
|
30
|
-
required: false,
|
|
31
|
-
char: "o",
|
|
32
|
-
description: "Output the results of the action to a specified file",
|
|
33
|
-
default: "translations_output.json",
|
|
34
|
-
}),
|
|
35
|
-
};
|
package/lib/config.js
DELETED
|
@@ -1,39 +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
|
-
exports.readConfig = exports.writeConfig = exports.deleteConfig = exports.configFileExists = void 0;
|
|
7
|
-
const os_1 = require("os");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = require("./fs");
|
|
10
|
-
const serialize_1 = require("./utils/serialize");
|
|
11
|
-
const configDirectory = path_1.default.join((0, os_1.homedir)(), ".config", "prism");
|
|
12
|
-
const configFilePath = path_1.default.join(configDirectory, "config.yml");
|
|
13
|
-
const ensureConfigDirectoryExists = async () => {
|
|
14
|
-
if (await (0, fs_1.exists)(configDirectory))
|
|
15
|
-
return;
|
|
16
|
-
await fs_1.fs.mkdir(configDirectory, { recursive: true });
|
|
17
|
-
};
|
|
18
|
-
const configFileExists = async () => (0, fs_1.exists)(configFilePath);
|
|
19
|
-
exports.configFileExists = configFileExists;
|
|
20
|
-
const deleteConfig = async () => {
|
|
21
|
-
if (!(await (0, exports.configFileExists)()))
|
|
22
|
-
return;
|
|
23
|
-
return fs_1.fs.unlink(configFilePath);
|
|
24
|
-
};
|
|
25
|
-
exports.deleteConfig = deleteConfig;
|
|
26
|
-
const writeConfig = async (config) => {
|
|
27
|
-
await ensureConfigDirectoryExists();
|
|
28
|
-
const contents = (0, serialize_1.dumpYaml)(config, { skipInvalid: true });
|
|
29
|
-
await fs_1.fs.writeFile(configFilePath, contents, { encoding: "utf-8" });
|
|
30
|
-
};
|
|
31
|
-
exports.writeConfig = writeConfig;
|
|
32
|
-
const readConfig = async () => {
|
|
33
|
-
if (!(await (0, exports.configFileExists)()))
|
|
34
|
-
return null;
|
|
35
|
-
const contents = await fs_1.fs.readFile(configFilePath, { encoding: "utf-8" });
|
|
36
|
-
const config = (await (0, serialize_1.loadYaml)(contents.toString()));
|
|
37
|
-
return config;
|
|
38
|
-
};
|
|
39
|
-
exports.readConfig = readConfig;
|
package/lib/errors.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processError = void 0;
|
|
4
|
-
const graphql_request_1 = require("graphql-request");
|
|
5
|
-
const http_status_codes_1 = require("http-status-codes");
|
|
6
|
-
const isOclifError = (error) => Boolean(error) &&
|
|
7
|
-
typeof error === "object" &&
|
|
8
|
-
error !== null &&
|
|
9
|
-
"oclif" in error;
|
|
10
|
-
const isError = (error) => Boolean(error) &&
|
|
11
|
-
typeof error === "object" &&
|
|
12
|
-
error !== null &&
|
|
13
|
-
"message" in error;
|
|
14
|
-
const getStatusMessage = (status) => {
|
|
15
|
-
if (status === http_status_codes_1.StatusCodes.OK) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
return status === http_status_codes_1.StatusCodes.UNAUTHORIZED
|
|
19
|
-
? "You are not logged to the Prismatic platform at the specified endpoint URL. Check the value for PRISMATIC_URL."
|
|
20
|
-
: (0, http_status_codes_1.getReasonPhrase)(status);
|
|
21
|
-
};
|
|
22
|
-
const extractResponseError = ({ response: { errors = [], status }, }) => {
|
|
23
|
-
try {
|
|
24
|
-
const statusMessage = getStatusMessage(status);
|
|
25
|
-
const errorMessages = errors.map(({ message }) => message);
|
|
26
|
-
return [statusMessage, ...errorMessages].filter(Boolean).join("\n");
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
return `GraphQL Error (Code: ${status})`;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
/** Accept arbitrary errors and convert them to OClif's error types. */
|
|
33
|
-
const processError = (error) => {
|
|
34
|
-
// Pass OclifErrors through unchanged
|
|
35
|
-
if (isOclifError(error)) {
|
|
36
|
-
return error;
|
|
37
|
-
}
|
|
38
|
-
// Try to process GraphQL errors into more user-friendly forms
|
|
39
|
-
if (error instanceof graphql_request_1.ClientError) {
|
|
40
|
-
return {
|
|
41
|
-
message: extractResponseError(error),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
// If a conventional error, only pass along the message for presentation
|
|
45
|
-
if (isError(error)) {
|
|
46
|
-
return {
|
|
47
|
-
message: error.message,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
// Last ditch best effort
|
|
51
|
-
return {
|
|
52
|
-
message: error,
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
exports.processError = processError;
|
package/lib/fields.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseJsonOrUndefined = exports.toValues = void 0;
|
|
4
|
-
const toValues = (rawValues) => {
|
|
5
|
-
if (!rawValues)
|
|
6
|
-
return undefined;
|
|
7
|
-
const obj = JSON.parse(rawValues);
|
|
8
|
-
return Object.entries(obj).reduce((result, [key, value]) => [...result, { key, value }], []);
|
|
9
|
-
};
|
|
10
|
-
exports.toValues = toValues;
|
|
11
|
-
const parseJsonOrUndefined = (json) => json ? JSON.parse(json) : undefined;
|
|
12
|
-
exports.parseJsonOrUndefined = parseJsonOrUndefined;
|
package/lib/fs.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fs = exports.readStdin = exports.exists = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return fs_1.promises; } });
|
|
6
|
-
const exists = async (path) => {
|
|
7
|
-
return fs_1.promises.access(path).then(() => true, () => false);
|
|
8
|
-
};
|
|
9
|
-
exports.exists = exists;
|
|
10
|
-
const readStdin = async () => {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
process.stdin
|
|
13
|
-
.on("readable", () => {
|
|
14
|
-
const result = process.stdin.read();
|
|
15
|
-
if (result !== null) {
|
|
16
|
-
process.stdin.removeAllListeners();
|
|
17
|
-
resolve(result.toString());
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
.on("error", reject);
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.readStdin = readStdin;
|
package/lib/generate/action.js
DELETED
|
@@ -1,208 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.generateActions = void 0;
|
|
30
|
-
const camelcase_1 = __importDefault(require("camelcase"));
|
|
31
|
-
const path = __importStar(require("path"));
|
|
32
|
-
const ts_morph_1 = require("ts-morph");
|
|
33
|
-
const parse_1 = require("./parse");
|
|
34
|
-
const input_1 = require("./input");
|
|
35
|
-
const util_1 = require("./util");
|
|
36
|
-
const lodash_1 = require("lodash");
|
|
37
|
-
const getPerformFunctionWSDL = (projectTemplatePath, action) => {
|
|
38
|
-
return `const client = await createClientAsync(path.join(__dirname, "${path.basename(projectTemplatePath)}"), headers);
|
|
39
|
-
const [result] = await client.${action.methodSignature.getName()}(${action.actionObject.inputs
|
|
40
|
-
.map((input) => {
|
|
41
|
-
return `{${input.shouldImport
|
|
42
|
-
? input.properties.map(({ propertyName }) => propertyName).join(", ")
|
|
43
|
-
: ""}}`;
|
|
44
|
-
})
|
|
45
|
-
.join(",")});`;
|
|
46
|
-
};
|
|
47
|
-
const instantiatePerformFunction = (action, project) => {
|
|
48
|
-
const { projectTemplatePath } = project;
|
|
49
|
-
const performFunction = getPerformFunctionWSDL(projectTemplatePath, action);
|
|
50
|
-
const performParams = action.actionObject.inputs
|
|
51
|
-
.filter(({ shouldImport }) => shouldImport)
|
|
52
|
-
.map(({ properties, shouldImport }) => {
|
|
53
|
-
const name = properties.map(({ propertyName }) => propertyName).join(",");
|
|
54
|
-
return shouldImport ? name : "";
|
|
55
|
-
});
|
|
56
|
-
const updatedPerformParams = [...performParams, "headers"];
|
|
57
|
-
return `async ({logger}, ${updatedPerformParams.length > 0
|
|
58
|
-
? `{ ${updatedPerformParams.join(", ")} }: Record<string,any>`
|
|
59
|
-
: ""}) => {
|
|
60
|
-
${performFunction}
|
|
61
|
-
return {data: result};
|
|
62
|
-
}`;
|
|
63
|
-
};
|
|
64
|
-
// Gather the definition of the type
|
|
65
|
-
// used as a parameter for our perform function
|
|
66
|
-
const generateActionObject = (methodSignature, project) => {
|
|
67
|
-
const inputPropertiesMapping = methodSignature
|
|
68
|
-
.getParameters()
|
|
69
|
-
.map((parameter) => {
|
|
70
|
-
const input = {
|
|
71
|
-
name: parameter.getName(),
|
|
72
|
-
properties: (0, input_1.getActionMethodInputProperties)(parameter, (0, parse_1.getParamTypeDefinition)(project, parameter)),
|
|
73
|
-
paramTypeDefinition: (0, parse_1.getParamTypeDefinition)(project, parameter),
|
|
74
|
-
};
|
|
75
|
-
input.shouldImport =
|
|
76
|
-
(input.properties.length > 0 &&
|
|
77
|
-
input.paramTypeDefinition !== undefined) ||
|
|
78
|
-
input.paramTypeDefinition === undefined;
|
|
79
|
-
return input;
|
|
80
|
-
});
|
|
81
|
-
return {
|
|
82
|
-
inputs: inputPropertiesMapping,
|
|
83
|
-
method: "",
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
// Compile all the information needed to build
|
|
87
|
-
// an action function
|
|
88
|
-
const compileAction = (actionService, actionMethod, project) => {
|
|
89
|
-
var _a;
|
|
90
|
-
return ({
|
|
91
|
-
service: actionService,
|
|
92
|
-
key: (0, camelcase_1.default)(actionMethod.getName()),
|
|
93
|
-
display: {
|
|
94
|
-
label: (0, camelcase_1.default)(actionMethod.getName(), { pascalCase: true })
|
|
95
|
-
.split(/(?=[A-Z])/)
|
|
96
|
-
.join(" "),
|
|
97
|
-
description: ((_a = actionMethod.getJsDocs()) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
98
|
-
? `${actionMethod.getJsDocs()[0].getDescription()}`
|
|
99
|
-
: "Generated by Prismatic.",
|
|
100
|
-
},
|
|
101
|
-
methodSignature: actionMethod,
|
|
102
|
-
actionObject: generateActionObject(actionMethod, project),
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
const writeAction = async (action, project) => {
|
|
106
|
-
const { actionFile } = project;
|
|
107
|
-
// Apparently you can't generate an Object without adding it to the file
|
|
108
|
-
// so this is our place holder to use as a template
|
|
109
|
-
const placeholder = actionFile.addVariableStatement({
|
|
110
|
-
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
111
|
-
declarations: [
|
|
112
|
-
{ name: "genericActionPayload", initializer: ts_morph_1.Writers.object({}) },
|
|
113
|
-
],
|
|
114
|
-
});
|
|
115
|
-
const object = placeholder
|
|
116
|
-
.getDeclarations()[0]
|
|
117
|
-
.getInitializer();
|
|
118
|
-
const inputFields = action.actionObject.inputs.flatMap(({ properties, shouldImport, name }) => {
|
|
119
|
-
if (properties.length > 0) {
|
|
120
|
-
return properties.map(({ propertyName }) => propertyName);
|
|
121
|
-
}
|
|
122
|
-
return shouldImport ? [name] : [];
|
|
123
|
-
});
|
|
124
|
-
object.addPropertyAssignments([
|
|
125
|
-
{
|
|
126
|
-
name: "display",
|
|
127
|
-
initializer: `{
|
|
128
|
-
label: "${action.display.label}",
|
|
129
|
-
description: \`${(0, util_1.createDescription)(action.display.description)}\`
|
|
130
|
-
}`,
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "perform",
|
|
134
|
-
initializer: instantiatePerformFunction(action, project),
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
name: "inputs",
|
|
138
|
-
initializer: `{${[
|
|
139
|
-
...inputFields,
|
|
140
|
-
`headers: {
|
|
141
|
-
label: "Headers",
|
|
142
|
-
type: "code",
|
|
143
|
-
comments: "Provide headers to the SOAP client",
|
|
144
|
-
default: '{}'
|
|
145
|
-
}`,
|
|
146
|
-
]}}`,
|
|
147
|
-
},
|
|
148
|
-
]);
|
|
149
|
-
//Add the action payload to the action
|
|
150
|
-
actionFile.addVariableStatement({
|
|
151
|
-
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
152
|
-
declarations: [
|
|
153
|
-
{
|
|
154
|
-
name: action.key,
|
|
155
|
-
initializer: `action(${object.print()})`,
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
isExported: true,
|
|
159
|
-
});
|
|
160
|
-
// Remove the temporary action object now that we've placed our payload
|
|
161
|
-
// into the action
|
|
162
|
-
placeholder.remove();
|
|
163
|
-
};
|
|
164
|
-
const writeServicesImport = async (services, { actionFile, definitionDirectory }) => {
|
|
165
|
-
actionFile.addImportDeclaration({
|
|
166
|
-
moduleSpecifier: `../${definitionDirectory}/index`,
|
|
167
|
-
namedImports: services,
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
const writeInputsImport = async (inputNames, { actionFile }) => {
|
|
171
|
-
actionFile.addImportDeclaration({
|
|
172
|
-
moduleSpecifier: "./inputs",
|
|
173
|
-
namedImports: inputNames,
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
const generateActions = async (project) => {
|
|
177
|
-
const { actionFile, inputsFile } = project;
|
|
178
|
-
const methods = (0, parse_1.getActionMethods)(project);
|
|
179
|
-
const actions = (0, lodash_1.sortBy)(Object.entries(methods).flatMap(([service, actionMethods]) => {
|
|
180
|
-
const dedupedActions = (0, lodash_1.uniqBy)(actionMethods, (a) => a.getName());
|
|
181
|
-
return dedupedActions.map((action) => compileAction(service, action, project));
|
|
182
|
-
}), ({ key }) => key);
|
|
183
|
-
const inputs = actions
|
|
184
|
-
.flatMap(({ actionObject }) => actionObject.inputs)
|
|
185
|
-
.filter(({ shouldImport }) => shouldImport)
|
|
186
|
-
.flatMap(({ properties }) => properties);
|
|
187
|
-
const dedupedInputs = (0, lodash_1.sortBy)((0, lodash_1.uniqBy)(inputs, (i) => i.propertyName.toLowerCase()), (i) => i.propertyName);
|
|
188
|
-
await (0, input_1.writeInputs)(project, dedupedInputs);
|
|
189
|
-
inputsFile.organizeImports();
|
|
190
|
-
inputsFile.formatText();
|
|
191
|
-
await inputsFile.save();
|
|
192
|
-
const services = actions.map(({ service }) => service);
|
|
193
|
-
const dedupedServices = (0, lodash_1.sortBy)((0, lodash_1.uniq)(services));
|
|
194
|
-
await writeServicesImport(dedupedServices, project);
|
|
195
|
-
const inputNames = dedupedInputs.map(({ propertyName }) => propertyName);
|
|
196
|
-
await writeInputsImport(inputNames, project);
|
|
197
|
-
const actionPromises = actions.map((action) => writeAction(action, project));
|
|
198
|
-
await Promise.all(actionPromises);
|
|
199
|
-
const actionExports = (0, lodash_1.sortBy)(actions.map(({ key }) => key));
|
|
200
|
-
actionFile.addExportAssignment({
|
|
201
|
-
isExportEquals: false,
|
|
202
|
-
expression: `{${actionExports.join(",\n")}}`,
|
|
203
|
-
});
|
|
204
|
-
actionFile.organizeImports();
|
|
205
|
-
actionFile.formatText();
|
|
206
|
-
await actionFile.save();
|
|
207
|
-
};
|
|
208
|
-
exports.generateActions = generateActions;
|
package/lib/generate/index.js
DELETED
|
@@ -1,54 +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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.updatePackageJson = exports.generate = void 0;
|
|
30
|
-
const path = __importStar(require("path"));
|
|
31
|
-
const sourceFile_1 = require("./sourceFile");
|
|
32
|
-
const action_1 = require("./action");
|
|
33
|
-
const prettier_1 = __importDefault(require("prettier"));
|
|
34
|
-
const fs_extra_1 = require("fs-extra");
|
|
35
|
-
const generate = async ({ projectRoot, projectTemplateName, projectTemplatePath, }) => {
|
|
36
|
-
var _a;
|
|
37
|
-
const project = (0, sourceFile_1.initializeProject)(projectRoot, projectTemplateName, projectTemplatePath);
|
|
38
|
-
const { componentProject } = project;
|
|
39
|
-
await (0, action_1.generateActions)(project);
|
|
40
|
-
(_a = componentProject
|
|
41
|
-
.getSourceFile(path.join(projectRoot, "src", "index.test.ts"))) === null || _a === void 0 ? void 0 : _a.delete();
|
|
42
|
-
await componentProject.save();
|
|
43
|
-
};
|
|
44
|
-
exports.generate = generate;
|
|
45
|
-
const updatePackageJson = async ({ path, dependencies = {}, devDependencies = {}, }) => {
|
|
46
|
-
const contents = await (0, fs_extra_1.readJson)(path, { encoding: "utf-8" });
|
|
47
|
-
Object.assign(contents.dependencies, dependencies);
|
|
48
|
-
Object.assign(contents.devDependencies, devDependencies);
|
|
49
|
-
const formatted = prettier_1.default.format(JSON.stringify(contents, null, 2), {
|
|
50
|
-
parser: "json",
|
|
51
|
-
});
|
|
52
|
-
await (0, fs_extra_1.writeFile)(path, formatted);
|
|
53
|
-
};
|
|
54
|
-
exports.updatePackageJson = updatePackageJson;
|