@prismatic-io/prism 5.0.2 → 5.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.
@@ -0,0 +1,71 @@
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 { customer } = flags;
9
+ let onPremiseResources = [];
10
+ let hasNextPage = true;
11
+ let cursor = "";
12
+ while (hasNextPage) {
13
+ const { onPremiseResources: { nodes, pageInfo }, } = await (0, graphql_1.gqlRequest)({
14
+ document: (0, graphql_1.gql) `
15
+ query listOnPremiseResources($after: String, $customer: ID) {
16
+ onPremiseResources(after: $after, customer: $customer) {
17
+ nodes {
18
+ id
19
+ name
20
+ customer {
21
+ id
22
+ name
23
+ externalId
24
+ }
25
+ port
26
+ status
27
+ }
28
+ pageInfo {
29
+ hasNextPage
30
+ endCursor
31
+ }
32
+ }
33
+ }
34
+ `,
35
+ variables: {
36
+ after: cursor,
37
+ customer,
38
+ },
39
+ });
40
+ onPremiseResources = [...onPremiseResources, ...nodes];
41
+ cursor = pageInfo.endCursor;
42
+ hasNextPage = pageInfo.hasNextPage;
43
+ }
44
+ core_1.ux.table(onPremiseResources, {
45
+ id: {
46
+ minWidth: 8,
47
+ extended: true,
48
+ },
49
+ name: {},
50
+ customerId: { extended: true, get: (row) => { var _a, _b; return (_b = (_a = row.customer) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : ""; } },
51
+ customer: {
52
+ get: (row) => { var _a, _b; return (_b = (_a = row.customer) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ""; },
53
+ },
54
+ customerExternalId: {
55
+ extended: true,
56
+ get: (row) => { var _a, _b; return (_b = (_a = row.customer) === null || _a === void 0 ? void 0 : _a.externalId) !== null && _b !== void 0 ? _b : ""; },
57
+ },
58
+ port: {},
59
+ status: {},
60
+ }, { ...flags });
61
+ }
62
+ }
63
+ exports.default = ListCommand;
64
+ ListCommand.description = "List On-Premise Resources";
65
+ ListCommand.flags = {
66
+ ...core_1.ux.table.flags(),
67
+ customer: core_1.Flags.string({
68
+ char: "c",
69
+ description: "If specified this command returns only On-Premise Resources that are available to the specified customer ID",
70
+ }),
71
+ };
@@ -0,0 +1,28 @@
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 result = await (0, graphql_1.gqlRequest)({
8
+ document: (0, graphql_1.gql) `
9
+ mutation createOnPremiseResourceJWT {
10
+ createOnPremiseResourceJWT(input: {}) {
11
+ result {
12
+ jwt
13
+ }
14
+ errors {
15
+ field
16
+ messages
17
+ }
18
+ }
19
+ }
20
+ `,
21
+ variables: {},
22
+ });
23
+ this.log(result.createOnPremiseResourceJWT.result.jwt);
24
+ }
25
+ }
26
+ exports.default = CreateCommand;
27
+ CreateCommand.description = "Create a short-lived JWT that may be used to perform registration of an On-Premise Resource.";
28
+ CreateCommand.flags = {};
@@ -0,0 +1,35 @@
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
+ };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GET_MARKETPLACE_INTEGRATIONS_TRANSLATIONS = void 0;
4
+ const graphql_1 = require("./graphql");
5
+ exports.GET_MARKETPLACE_INTEGRATIONS_TRANSLATIONS = (0, graphql_1.gql) `
6
+ fragment IntegrationTranslation on Integration {
7
+ name
8
+ description
9
+ definition
10
+ category
11
+ overview
12
+ configPages
13
+ requiredConfigVariables {
14
+ nodes {
15
+ key
16
+ description
17
+ inputs {
18
+ nodes {
19
+ name
20
+ meta
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ query MarketplaceTranslations {
27
+ marketplaceIntegrations {
28
+ nodes {
29
+ id
30
+ ...IntegrationTranslation
31
+ instances(isSystem: false) {
32
+ nodes {
33
+ id
34
+ name
35
+ integration {
36
+ ...IntegrationTranslation
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ `;
package/lib/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ // @generated
5
+ // This file was automatically generated and should not be edited.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processIntegrationsForTranslations = void 0;
4
+ const serialize_1 = require("../serialize");
5
+ const processedProperties = new Set();
6
+ const setResultProperty = (property) => {
7
+ if (property && !processedProperties.has(property)) {
8
+ processedProperties.add(property);
9
+ }
10
+ };
11
+ const processProperties = (properties) => {
12
+ properties.forEach((property) => setResultProperty(property));
13
+ };
14
+ const processIntegration = (integration) => {
15
+ const { name, description, category, overview, definition, instances } = integration;
16
+ processProperties([name, description, category, overview]);
17
+ if (definition) {
18
+ processIntegrationDefinition(definition);
19
+ }
20
+ if (!instances) {
21
+ return;
22
+ }
23
+ instances.nodes.forEach((instance) => processIntegrationInstance(instance));
24
+ };
25
+ const processIntegrationInstance = (instance) => {
26
+ if (!instance) {
27
+ return;
28
+ }
29
+ const { name, integration } = instance;
30
+ setResultProperty(name);
31
+ if (!integration) {
32
+ return;
33
+ }
34
+ processIntegration(instance.integration);
35
+ };
36
+ const processIntegrationDefinition = (unparsedYamlDefinition) => {
37
+ const definition = (0, serialize_1.loadYaml)(unparsedYamlDefinition);
38
+ const { category, description, configPages, flows, labels, requiredConfigVars, } = definition;
39
+ processProperties([description, category]);
40
+ configPages === null || configPages === void 0 ? void 0 : configPages.forEach((page) => {
41
+ setResultProperty(page.name);
42
+ setResultProperty(page.tagline);
43
+ page.elements.forEach((element) => setResultProperty(element.value));
44
+ });
45
+ flows === null || flows === void 0 ? void 0 : flows.forEach(traverse);
46
+ processProperties(labels !== null && labels !== void 0 ? labels : []);
47
+ requiredConfigVars === null || requiredConfigVars === void 0 ? void 0 : requiredConfigVars.forEach((configVar) => {
48
+ var _a, _b;
49
+ if (configVar.dataType === "date" ||
50
+ configVar.dataType === "timestamp" ||
51
+ configVar.dataType === "schedule") {
52
+ return;
53
+ }
54
+ setResultProperty(configVar.key);
55
+ setResultProperty(configVar.description);
56
+ if ("collectionType" in configVar) {
57
+ try {
58
+ const valueParsed = JSON.parse((_a = configVar.defaultValue) !== null && _a !== void 0 ? _a : "");
59
+ valueParsed.forEach((value) => {
60
+ if (typeof value === "string") {
61
+ setResultProperty(value);
62
+ }
63
+ if (typeof value === "object") {
64
+ Object.entries(value).forEach(([key, value]) => {
65
+ setResultProperty(key);
66
+ setResultProperty(value);
67
+ });
68
+ }
69
+ });
70
+ }
71
+ catch (error) {
72
+ console.error(`JSON Parsing Error: ${error}`);
73
+ }
74
+ }
75
+ if (configVar.dataType === "picklist") {
76
+ processProperties((_b = configVar.pickList) !== null && _b !== void 0 ? _b : []);
77
+ }
78
+ });
79
+ };
80
+ const traverse = (flowOrStep) => {
81
+ var _a, _b;
82
+ const stack = [flowOrStep];
83
+ while (stack.length > 0) {
84
+ const current = stack.pop();
85
+ if (current === undefined)
86
+ continue;
87
+ if (isFlow(current)) {
88
+ // Handling Flow type
89
+ processProperties([current.name, current.description]);
90
+ stack.push(...current.steps);
91
+ }
92
+ else if (isStep(current)) {
93
+ // Handling Step type
94
+ processProperties([
95
+ current.name,
96
+ current.description,
97
+ (_b = (_a = current.action) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.key,
98
+ ]);
99
+ if (current.steps) {
100
+ stack.push(...current.steps);
101
+ }
102
+ if (current.branches) {
103
+ stack.push(...current.branches.map((branch) => ({
104
+ name: branch.name,
105
+ steps: branch.steps,
106
+ })));
107
+ }
108
+ }
109
+ else {
110
+ // Handling Branch type
111
+ setResultProperty(current.name);
112
+ stack.push(...current.steps);
113
+ }
114
+ }
115
+ };
116
+ const isFlow = (object) => {
117
+ return "steps" in object && Array.isArray(object.steps);
118
+ };
119
+ const isStep = (object) => {
120
+ return "action" in object;
121
+ };
122
+ const processIntegrationsForTranslations = (data) => {
123
+ data.marketplaceIntegrations.nodes.forEach((integration) => {
124
+ if (!integration) {
125
+ return;
126
+ }
127
+ processIntegration(integration);
128
+ });
129
+ const result = Object.fromEntries(processedProperties.entries());
130
+ return result;
131
+ };
132
+ exports.processIntegrationsForTranslations = processIntegrationsForTranslations;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.0.2",
2
+ "version": "5.2.0",
3
3
  "commands": {
4
4
  "login": {
5
5
  "id": "login",
@@ -1142,6 +1142,109 @@
1142
1142
  },
1143
1143
  "args": {}
1144
1144
  },
1145
+ "on-prem-resources:list": {
1146
+ "id": "on-prem-resources:list",
1147
+ "description": "List On-Premise Resources",
1148
+ "strict": true,
1149
+ "pluginName": "@prismatic-io/prism",
1150
+ "pluginAlias": "@prismatic-io/prism",
1151
+ "pluginType": "core",
1152
+ "aliases": [],
1153
+ "flags": {
1154
+ "columns": {
1155
+ "name": "columns",
1156
+ "type": "option",
1157
+ "description": "only show provided columns (comma-separated)",
1158
+ "multiple": false,
1159
+ "exclusive": [
1160
+ "extended"
1161
+ ]
1162
+ },
1163
+ "sort": {
1164
+ "name": "sort",
1165
+ "type": "option",
1166
+ "description": "property to sort by (prepend '-' for descending)",
1167
+ "multiple": false
1168
+ },
1169
+ "filter": {
1170
+ "name": "filter",
1171
+ "type": "option",
1172
+ "description": "filter property by partial string matching, ex: name=foo",
1173
+ "multiple": false
1174
+ },
1175
+ "csv": {
1176
+ "name": "csv",
1177
+ "type": "boolean",
1178
+ "description": "output is csv format [alias: --output=csv]",
1179
+ "allowNo": false,
1180
+ "exclusive": [
1181
+ "no-truncate"
1182
+ ]
1183
+ },
1184
+ "output": {
1185
+ "name": "output",
1186
+ "type": "option",
1187
+ "description": "output in a more machine friendly format",
1188
+ "multiple": false,
1189
+ "options": [
1190
+ "csv",
1191
+ "json",
1192
+ "yaml"
1193
+ ],
1194
+ "exclusive": [
1195
+ "no-truncate",
1196
+ "csv"
1197
+ ]
1198
+ },
1199
+ "extended": {
1200
+ "name": "extended",
1201
+ "type": "boolean",
1202
+ "char": "x",
1203
+ "description": "show extra columns",
1204
+ "allowNo": false,
1205
+ "exclusive": [
1206
+ "columns"
1207
+ ]
1208
+ },
1209
+ "no-truncate": {
1210
+ "name": "no-truncate",
1211
+ "type": "boolean",
1212
+ "description": "do not truncate output to fit screen",
1213
+ "allowNo": false,
1214
+ "exclusive": [
1215
+ "csv"
1216
+ ]
1217
+ },
1218
+ "no-header": {
1219
+ "name": "no-header",
1220
+ "type": "boolean",
1221
+ "description": "hide table header from output",
1222
+ "allowNo": false,
1223
+ "exclusive": [
1224
+ "csv"
1225
+ ]
1226
+ },
1227
+ "customer": {
1228
+ "name": "customer",
1229
+ "type": "option",
1230
+ "char": "c",
1231
+ "description": "If specified this command returns only On-Premise Resources that are available to the specified customer ID",
1232
+ "multiple": false
1233
+ }
1234
+ },
1235
+ "args": {}
1236
+ },
1237
+ "on-prem-resources:registration-jwt": {
1238
+ "id": "on-prem-resources:registration-jwt",
1239
+ "description": "Create a short-lived JWT that may be used to perform registration of an On-Premise Resource.",
1240
+ "strict": true,
1241
+ "pluginName": "@prismatic-io/prism",
1242
+ "pluginAlias": "@prismatic-io/prism",
1243
+ "pluginType": "core",
1244
+ "aliases": [],
1245
+ "flags": {},
1246
+ "args": {}
1247
+ },
1145
1248
  "organization:update": {
1146
1249
  "id": "organization:update",
1147
1250
  "description": "Update your Organization",
@@ -1188,6 +1291,27 @@
1188
1291
  },
1189
1292
  "args": {}
1190
1293
  },
1294
+ "translations:list": {
1295
+ "id": "translations:list",
1296
+ "description": "Generate Dynamic Phrases for Embedded Marketplace",
1297
+ "strict": true,
1298
+ "pluginName": "@prismatic-io/prism",
1299
+ "pluginAlias": "@prismatic-io/prism",
1300
+ "pluginType": "core",
1301
+ "aliases": [],
1302
+ "flags": {
1303
+ "output-file": {
1304
+ "name": "output-file",
1305
+ "type": "option",
1306
+ "char": "o",
1307
+ "description": "Output the results of the action to a specified file",
1308
+ "required": false,
1309
+ "multiple": false,
1310
+ "default": "translations_output.json"
1311
+ }
1312
+ },
1313
+ "args": {}
1314
+ },
1191
1315
  "alerts:events:list": {
1192
1316
  "id": "alerts:events:list",
1193
1317
  "description": "List Alert Events for an Alert Monitor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/prism",
3
- "version": "5.0.2",
3
+ "version": "5.2.0",
4
4
  "description": "Build, deploy, and support integrations in Prismatic from the comfort of your command line",
5
5
  "keywords": [
6
6
  "prismatic",
@@ -164,6 +164,9 @@
164
164
  },
165
165
  "organization:users": {
166
166
  "description": "Manage Organization Users"
167
+ },
168
+ "translations:list": {
169
+ "description": "Generates phrases for all marketplace integrations"
167
170
  }
168
171
  }
169
172
  },