@prismatic-io/prism 5.0.1 → 5.1.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,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.1",
2
+ "version": "5.1.0",
3
3
  "commands": {
4
4
  "login": {
5
5
  "id": "login",
@@ -1188,6 +1188,27 @@
1188
1188
  },
1189
1189
  "args": {}
1190
1190
  },
1191
+ "translations:list": {
1192
+ "id": "translations:list",
1193
+ "description": "Generate Dynamic Phrases for Embedded Marketplace",
1194
+ "strict": true,
1195
+ "pluginName": "@prismatic-io/prism",
1196
+ "pluginAlias": "@prismatic-io/prism",
1197
+ "pluginType": "core",
1198
+ "aliases": [],
1199
+ "flags": {
1200
+ "output-file": {
1201
+ "name": "output-file",
1202
+ "type": "option",
1203
+ "char": "o",
1204
+ "description": "Output the results of the action to a specified file",
1205
+ "required": false,
1206
+ "multiple": false,
1207
+ "default": "translations_output.json"
1208
+ }
1209
+ },
1210
+ "args": {}
1211
+ },
1191
1212
  "alerts:events:list": {
1192
1213
  "id": "alerts:events:list",
1193
1214
  "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.1",
3
+ "version": "5.1.0",
4
4
  "description": "Build, deploy, and support integrations in Prismatic from the comfort of your command line",
5
5
  "keywords": [
6
6
  "prismatic",
@@ -45,8 +45,8 @@
45
45
  "@oclif/plugin-autocomplete": "2.3.6",
46
46
  "@oclif/plugin-help": "5.2.17",
47
47
  "@oclif/plugin-warn-if-update-available": "2.0.48",
48
- "@prismatic-io/generator-spectral": "3.0.0",
49
- "@prismatic-io/spectral": "8.0.0",
48
+ "@prismatic-io/generator-spectral": "3.0.1",
49
+ "@prismatic-io/spectral": "8.0.1",
50
50
  "archiver": "3.1.1",
51
51
  "axios": "1.6.2",
52
52
  "camelcase": "6.2.0",
@@ -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
  },