@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.
Files changed (160) hide show
  1. package/lib/index.js +32973 -5
  2. package/lib/run.js +365 -0
  3. package/lib/templates/action/action.ts.ejs +33 -0
  4. package/lib/templates/component/assets/icon.png.ejs +0 -0
  5. package/lib/templates/component/jest.config.js.ejs +4 -0
  6. package/lib/templates/component/package.json.ejs +6 -0
  7. package/lib/templates/component/src/client.ts.ejs +10 -0
  8. package/lib/templates/component/src/index.test.ts.ejs +47 -0
  9. package/lib/templates/component/src/index.ts.ejs +19 -0
  10. package/lib/templates/component/tsconfig.json.ejs +12 -0
  11. package/lib/templates/component/webpack.config.js.ejs +36 -0
  12. package/lib/templates/connection/basic.ts.ejs +25 -0
  13. package/lib/templates/connection/oauth.ts.ejs +65 -0
  14. package/lib/templates/dataSource/dataSource.ts.ejs +34 -0
  15. package/lib/templates/flow/flow.ts.ejs +37 -0
  16. package/lib/templates/formats/assets/icon.png.ejs +0 -0
  17. package/lib/templates/formats/jest.config.js.ejs +4 -0
  18. package/lib/templates/formats/tsconfig.json.ejs +12 -0
  19. package/lib/templates/formats/webpack.config.js.ejs +36 -0
  20. package/lib/templates/integration/assets/icon.png.ejs +0 -0
  21. package/lib/templates/integration/basic.ts.ejs +29 -0
  22. package/lib/templates/integration/jest.config.js.ejs +4 -0
  23. package/lib/templates/integration/oauth.ts.ejs +69 -0
  24. package/lib/templates/integration/package.json.ejs +6 -0
  25. package/lib/templates/integration/src/client.ts.ejs +10 -0
  26. package/lib/templates/integration/src/index.test.ts.ejs +18 -0
  27. package/lib/templates/integration/src/index.ts.ejs +11 -0
  28. package/lib/templates/integration/tsconfig.json.ejs +12 -0
  29. package/lib/templates/integration/webpack.config.js.ejs +36 -0
  30. package/lib/templates/trigger/trigger.ts.ejs +19 -0
  31. package/oclif.manifest.json +3153 -2451
  32. package/package.json +56 -60
  33. package/bin/run +0 -12
  34. package/lib/auth.js +0 -323
  35. package/lib/commands/alerts/events/list.js +0 -56
  36. package/lib/commands/alerts/groups/create.js +0 -58
  37. package/lib/commands/alerts/groups/delete.js +0 -35
  38. package/lib/commands/alerts/groups/list.js +0 -44
  39. package/lib/commands/alerts/monitors/clear.js +0 -35
  40. package/lib/commands/alerts/monitors/create.js +0 -102
  41. package/lib/commands/alerts/monitors/delete.js +0 -35
  42. package/lib/commands/alerts/monitors/list.js +0 -63
  43. package/lib/commands/alerts/triggers/list.js +0 -31
  44. package/lib/commands/alerts/webhooks/create.js +0 -67
  45. package/lib/commands/alerts/webhooks/delete.js +0 -35
  46. package/lib/commands/alerts/webhooks/list.js +0 -57
  47. package/lib/commands/components/actions/list.js +0 -96
  48. package/lib/commands/components/data-sources/list.js +0 -114
  49. package/lib/commands/components/delete.js +0 -35
  50. package/lib/commands/components/dev/run.js +0 -83
  51. package/lib/commands/components/dev/test.js +0 -266
  52. package/lib/commands/components/init/action.js +0 -12
  53. package/lib/commands/components/init/component.js +0 -12
  54. package/lib/commands/components/init/connection.js +0 -12
  55. package/lib/commands/components/init/dataSource.js +0 -12
  56. package/lib/commands/components/init/index.js +0 -126
  57. package/lib/commands/components/init/trigger.js +0 -12
  58. package/lib/commands/components/list.js +0 -95
  59. package/lib/commands/components/publish.js +0 -62
  60. package/lib/commands/components/triggers/list.js +0 -96
  61. package/lib/commands/customers/create.js +0 -72
  62. package/lib/commands/customers/credentials/create.js +0 -68
  63. package/lib/commands/customers/credentials/delete.js +0 -35
  64. package/lib/commands/customers/credentials/list.js +0 -56
  65. package/lib/commands/customers/credentials/update.js +0 -58
  66. package/lib/commands/customers/delete.js +0 -35
  67. package/lib/commands/customers/list.js +0 -51
  68. package/lib/commands/customers/update.js +0 -82
  69. package/lib/commands/customers/users/create.js +0 -67
  70. package/lib/commands/customers/users/delete.js +0 -35
  71. package/lib/commands/customers/users/list.js +0 -65
  72. package/lib/commands/customers/users/roles.js +0 -33
  73. package/lib/commands/customers/users/update.js +0 -76
  74. package/lib/commands/executions/step-result/get.js +0 -73
  75. package/lib/commands/instances/config-vars/list.js +0 -83
  76. package/lib/commands/instances/create.js +0 -84
  77. package/lib/commands/instances/delete.js +0 -35
  78. package/lib/commands/instances/deploy.js +0 -43
  79. package/lib/commands/instances/disable.js +0 -36
  80. package/lib/commands/instances/enable.js +0 -36
  81. package/lib/commands/instances/flow-configs/list.js +0 -62
  82. package/lib/commands/instances/flow-configs/test.js +0 -127
  83. package/lib/commands/instances/list.js +0 -86
  84. package/lib/commands/instances/update.js +0 -99
  85. package/lib/commands/integrations/available.js +0 -47
  86. package/lib/commands/integrations/create.js +0 -58
  87. package/lib/commands/integrations/delete.js +0 -35
  88. package/lib/commands/integrations/export.js +0 -29
  89. package/lib/commands/integrations/flows/list.js +0 -61
  90. package/lib/commands/integrations/flows/test.js +0 -124
  91. package/lib/commands/integrations/fork.js +0 -56
  92. package/lib/commands/integrations/import.js +0 -54
  93. package/lib/commands/integrations/init/flow.js +0 -12
  94. package/lib/commands/integrations/init/index.js +0 -45
  95. package/lib/commands/integrations/init/integration.js +0 -12
  96. package/lib/commands/integrations/list.js +0 -96
  97. package/lib/commands/integrations/marketplace.js +0 -80
  98. package/lib/commands/integrations/open.js +0 -18
  99. package/lib/commands/integrations/publish.js +0 -44
  100. package/lib/commands/integrations/update.js +0 -75
  101. package/lib/commands/integrations/versions/index.js +0 -83
  102. package/lib/commands/login.js +0 -33
  103. package/lib/commands/logout.js +0 -23
  104. package/lib/commands/logs/severities/list.js +0 -29
  105. package/lib/commands/me/index.js +0 -22
  106. package/lib/commands/me/token/revoke.js +0 -12
  107. package/lib/commands/me/token.js +0 -25
  108. package/lib/commands/on-prem-resources/delete.js +0 -35
  109. package/lib/commands/on-prem-resources/list.js +0 -69
  110. package/lib/commands/on-prem-resources/registration-jwt.js +0 -81
  111. package/lib/commands/organization/credentials/create.js +0 -60
  112. package/lib/commands/organization/credentials/delete.js +0 -35
  113. package/lib/commands/organization/credentials/list.js +0 -45
  114. package/lib/commands/organization/credentials/update.js +0 -58
  115. package/lib/commands/organization/signingKeys/delete.js +0 -35
  116. package/lib/commands/organization/signingKeys/generate.js +0 -22
  117. package/lib/commands/organization/signingKeys/import.js +0 -40
  118. package/lib/commands/organization/signingKeys/list.js +0 -36
  119. package/lib/commands/organization/update.js +0 -37
  120. package/lib/commands/organization/updateAvatarUrl.js +0 -47
  121. package/lib/commands/organization/users/create.js +0 -51
  122. package/lib/commands/organization/users/delete.js +0 -35
  123. package/lib/commands/organization/users/list.js +0 -60
  124. package/lib/commands/organization/users/roles.js +0 -33
  125. package/lib/commands/organization/users/update.js +0 -66
  126. package/lib/commands/translations/list.js +0 -35
  127. package/lib/config.js +0 -39
  128. package/lib/errors.js +0 -55
  129. package/lib/fields.js +0 -12
  130. package/lib/fs.js +0 -23
  131. package/lib/generate/action.js +0 -208
  132. package/lib/generate/index.js +0 -54
  133. package/lib/generate/input.js +0 -93
  134. package/lib/generate/parse.js +0 -59
  135. package/lib/generate/sourceFile.js +0 -90
  136. package/lib/generate/util.js +0 -17
  137. package/lib/graphql.js +0 -42
  138. package/lib/queries.graphql.js +0 -43
  139. package/lib/types.js +0 -6
  140. package/lib/utils/avatar.js +0 -48
  141. package/lib/utils/component/deleteByKey.js +0 -36
  142. package/lib/utils/component/publish.js +0 -247
  143. package/lib/utils/component/query.js +0 -23
  144. package/lib/utils/date.js +0 -14
  145. package/lib/utils/execution/logs.js +0 -86
  146. package/lib/utils/execution/stepResults.js +0 -87
  147. package/lib/utils/generate.js +0 -50
  148. package/lib/utils/import.js +0 -21
  149. package/lib/utils/integration/definition.js +0 -101
  150. package/lib/utils/integration/export.js +0 -36
  151. package/lib/utils/integration/import.js +0 -179
  152. package/lib/utils/integration/invoke.js +0 -81
  153. package/lib/utils/integration/open.js +0 -37
  154. package/lib/utils/integration/query.js +0 -59
  155. package/lib/utils/process.js +0 -15
  156. package/lib/utils/serialize.js +0 -8
  157. package/lib/utils/translations/processDataForTranslations.js +0 -132
  158. package/lib/utils/user/query.js +0 -26
  159. package/lib/yeoman.js +0 -27
  160. /package/{bin → lib}/run.cmd +0 -0
@@ -1,179 +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.waitForCodeNativeComponentAvailable = exports.loadCodeNativeIntegrationEntryPoint = exports.importCodeNativeIntegration = exports.importYamlIntegration = exports.importDefinition = void 0;
7
- const chardet_1 = __importDefault(require("chardet"));
8
- const core_1 = require("@oclif/core");
9
- const graphql_1 = require("../../graphql");
10
- const avatar_1 = require("../../utils/avatar");
11
- const fs_1 = require("../../fs");
12
- const path_1 = require("path");
13
- const import_1 = require("../import");
14
- const publish_1 = require("../component/publish");
15
- const importDefinition = async (definition, integrationId) => {
16
- const result = await (0, graphql_1.gqlRequest)({
17
- document: (0, graphql_1.gql) `
18
- mutation importIntegration($definition: String!, $integrationId: ID) {
19
- importIntegration(
20
- input: { definition: $definition, integrationId: $integrationId }
21
- ) {
22
- integration {
23
- id
24
- flows {
25
- nodes {
26
- id
27
- name
28
- }
29
- }
30
- testConfigVariables(status: "pending") {
31
- nodes {
32
- id
33
- authorizeUrl
34
- }
35
- }
36
- }
37
- errors {
38
- field
39
- messages
40
- }
41
- }
42
- }
43
- `,
44
- variables: {
45
- definition,
46
- integrationId,
47
- },
48
- });
49
- const integration = result.importIntegration.integration;
50
- return {
51
- integrationId: integration.id,
52
- flows: integration.flows.nodes,
53
- pendingAuthorizations: integration.testConfigVariables.nodes.map(({ id, authorizeUrl: url }) => ({ id, url })),
54
- };
55
- };
56
- exports.importDefinition = importDefinition;
57
- const setIntegrationAvatar = async (integrationId, iconPath) => {
58
- try {
59
- const avatarUrl = await (0, avatar_1.uploadAvatar)(integrationId, iconPath);
60
- await (0, graphql_1.gqlRequest)({
61
- document: (0, graphql_1.gql) `
62
- mutation commitAvatarUpload($integrationId: ID!, $avatarUrl: String!) {
63
- updateIntegration(
64
- input: { id: $integrationId, avatarUrl: $avatarUrl }
65
- ) {
66
- integration {
67
- id
68
- }
69
- errors {
70
- field
71
- messages
72
- }
73
- }
74
- }
75
- `,
76
- variables: {
77
- integrationId,
78
- avatarUrl,
79
- },
80
- });
81
- }
82
- catch (err) {
83
- console.warn(`Error setting integration icon: ${err}`);
84
- }
85
- };
86
- const importYamlIntegration = async (path, integrationId, iconPath) => {
87
- const encoding = await chardet_1.default.detectFile(path);
88
- const definition = await fs_1.fs.readFile(path, encoding === "UTF-16LE" ? "utf16le" : "utf-8");
89
- const { integrationId: integrationImportId } = await (0, exports.importDefinition)(definition, integrationId);
90
- if (iconPath) {
91
- await setIntegrationAvatar(integrationImportId, iconPath);
92
- }
93
- return integrationImportId;
94
- };
95
- exports.importYamlIntegration = importYamlIntegration;
96
- const importCodeNativeIntegration = async (integrationId) => {
97
- const { integrationDefinition, componentDefinition } = await (0, exports.loadCodeNativeIntegrationEntryPoint)();
98
- if (!integrationDefinition) {
99
- core_1.ux.error("Failed to find Code Native Integration definition in 'index.js' entrypoint file. Is the current path a Code Native Integration?", { exit: 1 });
100
- }
101
- await (0, publish_1.validateDefinition)(componentDefinition);
102
- const packagePath = await (0, publish_1.createComponentPackage)();
103
- const { iconUploadUrl, packageUploadUrl, connectionIconUploadUrls, versionNumber, } = await (0, publish_1.publishDefinition)(componentDefinition, undefined, undefined, true);
104
- core_1.ux.action.start("Uploading package for Code Native Integration");
105
- await (0, publish_1.uploadFile)(packagePath, packageUploadUrl);
106
- const uploaded = await (0, exports.waitForCodeNativeComponentAvailable)(componentDefinition.key, versionNumber);
107
- if (uploaded) {
108
- core_1.ux.action.stop();
109
- }
110
- else {
111
- core_1.ux.action.stop("Package still processing for Code Native Integration, it will likely be available in a few minutes.");
112
- }
113
- core_1.ux.action.start("Importing definition for Code Native Integration into Prismatic");
114
- const { integrationId: integrationImportId } = await (0, exports.importDefinition)(integrationDefinition, integrationId);
115
- const { display: { iconPath }, } = componentDefinition;
116
- if (iconPath) {
117
- await (0, publish_1.uploadFile)(iconPath, iconUploadUrl); // Component avatar.
118
- await setIntegrationAvatar(integrationImportId, iconPath); // Integration avatar.
119
- }
120
- await (0, publish_1.uploadConnectionIcons)(componentDefinition, connectionIconUploadUrls);
121
- core_1.ux.action.stop();
122
- return integrationImportId;
123
- };
124
- exports.importCodeNativeIntegration = importCodeNativeIntegration;
125
- const loadCodeNativeIntegrationEntryPoint = async () => {
126
- // If we don't have an index.js in cwd seek directories to find package.json of Code Native Integration
127
- if (!(await (0, fs_1.exists)("index.js"))) {
128
- await (0, import_1.seekPackageDistDirectory)("Code Native Integration");
129
- }
130
- // If we still didn't find index.js error out
131
- if (!(await (0, fs_1.exists)("index.js"))) {
132
- core_1.ux.error("Failed to find 'index.js' entrypoint file. Is the current path a Code Native Integration?", { exit: 1 });
133
- }
134
- // Require index.js and access its root-most default export which should contain the YAML definition.
135
- const cwd = process.cwd();
136
- const entrypointPath = (0, path_1.resolve)(cwd, "./index.js");
137
- const { default: componentDefinition, } = require(entrypointPath); // eslint-disable-line @typescript-eslint/no-var-requires
138
- return {
139
- integrationDefinition: componentDefinition.codeNativeIntegrationYAML,
140
- componentDefinition: componentDefinition,
141
- };
142
- };
143
- exports.loadCodeNativeIntegrationEntryPoint = loadCodeNativeIntegrationEntryPoint;
144
- const waitForCodeNativeComponentAvailable = async (componentKey, versionNumber, attemptNumber = 0, maximumAttempts = 10) => {
145
- // Retrieve the current availability status.
146
- const results = await (0, graphql_1.gqlRequest)({
147
- document: (0, graphql_1.gql) `
148
- query component($componentKey: String!, $versionNumber: Int!) {
149
- components(
150
- key: $componentKey
151
- versionNumber: $versionNumber
152
- public: false
153
- includeComponentsForCodeNativeIntegrations: true
154
- ) {
155
- nodes {
156
- versionIsAvailable
157
- }
158
- }
159
- }
160
- `,
161
- variables: {
162
- componentKey,
163
- versionNumber,
164
- },
165
- });
166
- const { components: { nodes: [{ versionIsAvailable }], }, } = results;
167
- if (versionIsAvailable) {
168
- // Component is ready.
169
- return versionIsAvailable;
170
- }
171
- else if (attemptNumber < maximumAttempts) {
172
- // Wait 1 second and try again.
173
- await new Promise((resolve) => setTimeout(resolve, 1000));
174
- return (0, exports.waitForCodeNativeComponentAvailable)(componentKey, versionNumber, attemptNumber + 1, maximumAttempts);
175
- }
176
- // Component is still not ready, so bail out.
177
- return false;
178
- };
179
- exports.waitForCodeNativeComponentAvailable = waitForCodeNativeComponentAvailable;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runIntegrationFlow = exports.deleteIntegration = exports.getIntegrationFlow = void 0;
4
- const graphql_1 = require("../../graphql");
5
- /** Return Flow ID of given flow name on specified Integration. */
6
- const getIntegrationFlow = async (integrationId, flowName) => {
7
- // TODO: Make flows searchable by name.
8
- const result = await (0, graphql_1.gqlRequest)({
9
- document: (0, graphql_1.gql) `
10
- query flowId($integrationID: ID!) {
11
- integration(id: $id) {
12
- flows {
13
- nodes {
14
- id
15
- name
16
- }
17
- }
18
- }
19
- }
20
- `,
21
- variables: { integrationID: integrationId },
22
- });
23
- const integration = result.integration;
24
- const flows = integration.flows.nodes
25
- .map(({ id, name }) => ({
26
- id,
27
- name: name.toLowerCase().trim(),
28
- }))
29
- .filter(({ name }) => name === flowName);
30
- if (flows.length > 1) {
31
- throw new Error(`Found more than one result for Flow name: ${flowName}`);
32
- }
33
- if (flows.length === 0) {
34
- throw new Error(`Failed to find a Flow with the given name: ${flowName}`);
35
- }
36
- return flows[0].id;
37
- };
38
- exports.getIntegrationFlow = getIntegrationFlow;
39
- /** Delete a specified integration by ID */
40
- const deleteIntegration = async (integrationId) => {
41
- await (0, graphql_1.gqlRequest)({
42
- document: (0, graphql_1.gql) `
43
- mutation deleteIntegration($id: ID!) {
44
- deleteIntegration(input: { id: $id }) {
45
- errors {
46
- field
47
- messages
48
- }
49
- }
50
- }
51
- `,
52
- variables: { id: integrationId },
53
- });
54
- };
55
- exports.deleteIntegration = deleteIntegration;
56
- const runIntegrationFlow = async ({ integrationId, flowId, flowName, }) => {
57
- const integrationFlowId = flowName
58
- ? await (0, exports.getIntegrationFlow)(integrationId, flowName)
59
- : flowId;
60
- const result = await (0, graphql_1.gqlRequest)({
61
- document: (0, graphql_1.gql) `
62
- mutation testIntegrationFlow($id: ID!) {
63
- testIntegrationFlow(input: { id: $id }) {
64
- testIntegrationFlowResult {
65
- execution {
66
- id
67
- }
68
- }
69
- errors {
70
- field
71
- messages
72
- }
73
- }
74
- }
75
- `,
76
- variables: { id: integrationFlowId },
77
- });
78
- const executionId = result.testIntegrationFlow.testIntegrationFlowResult.execution.id;
79
- return { executionId };
80
- };
81
- exports.runIntegrationFlow = runIntegrationFlow;
@@ -1,37 +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.openIntegration = void 0;
30
- const path = __importStar(require("path"));
31
- const open_1 = __importDefault(require("open"));
32
- const auth_1 = require("../../auth");
33
- const openIntegration = async (integrationId) => {
34
- const url = new URL(path.join("designer", integrationId), auth_1.prismaticUrl);
35
- await (0, open_1.default)(url.href);
36
- };
37
- exports.openIntegration = openIntegration;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pollForActiveConfigVarState = exports.integrationByName = void 0;
4
- const graphql_1 = require("../../graphql");
5
- const integrationByName = async (name) => {
6
- const result = await (0, graphql_1.gqlRequest)({
7
- document: (0, graphql_1.gql) `
8
- query integration($name: String!) {
9
- integrations(name: $name) {
10
- nodes {
11
- id
12
- }
13
- }
14
- }
15
- `,
16
- variables: { name },
17
- });
18
- const [integration, ...rest] = result.integrations.nodes;
19
- if (rest.length !== 0) {
20
- throw new Error(`Found more than one Integration with name: ${name}`);
21
- }
22
- return integration;
23
- };
24
- exports.integrationByName = integrationByName;
25
- const pollForActiveConfigVarState = async (integrationId, configVarId) => {
26
- return new Promise((resolve, reject) => {
27
- const interval = setInterval(async () => {
28
- try {
29
- const result = await (0, graphql_1.gqlRequest)({
30
- document: (0, graphql_1.gql) `
31
- query state($integrationId: ID!) {
32
- integration(id: $integrationId) {
33
- testConfigVariables(status_In: ["pending", "active", "error"]) {
34
- nodes {
35
- id
36
- status
37
- }
38
- }
39
- }
40
- }
41
- `,
42
- variables: { integrationId },
43
- });
44
- const testConfigVariables = result.integration.testConfigVariables.nodes;
45
- const [{ status: serverStatus }] = testConfigVariables.filter(({ id }) => id === configVarId);
46
- const status = serverStatus.toLowerCase();
47
- if (status !== "pending") {
48
- clearInterval(interval);
49
- resolve(status === "active");
50
- }
51
- }
52
- catch (error) {
53
- clearInterval(interval);
54
- reject(error);
55
- }
56
- }, 5000);
57
- });
58
- };
59
- exports.pollForActiveConfigVarState = pollForActiveConfigVarState;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.spawnProcess = void 0;
4
- const child_process_1 = require("child_process");
5
- const spawnProcess = ([command, ...args], env) => {
6
- return new Promise((resolve, reject) => {
7
- const child = (0, child_process_1.spawn)(command, args, {
8
- env: { ...process.env, ...env },
9
- });
10
- child.stdout.pipe(process.stdout);
11
- child.stderr.pipe(process.stderr);
12
- child.on("close", (code) => (code === 0 ? resolve() : reject()));
13
- });
14
- };
15
- exports.spawnProcess = spawnProcess;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadYaml = exports.dumpYaml = void 0;
4
- const js_yaml_1 = require("js-yaml");
5
- const dumpYaml = (value, extraOptions) => (0, js_yaml_1.dump)(value, { ...extraOptions, noRefs: true });
6
- exports.dumpYaml = dumpYaml;
7
- const loadYaml = (value, extraOptions) => (0, js_yaml_1.load)(value, { ...extraOptions });
8
- exports.loadYaml = loadYaml;
@@ -1,132 +0,0 @@
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,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.whoAmI = void 0;
4
- const graphql_1 = require("../../graphql");
5
- const whoAmI = async () => {
6
- const { authenticatedUser } = await (0, graphql_1.gqlRequest)({
7
- document: (0, graphql_1.gql) `
8
- query whoami {
9
- authenticatedUser {
10
- name
11
- email
12
- org {
13
- name
14
- }
15
- customer {
16
- id
17
- name
18
- }
19
- }
20
- }
21
- `,
22
- });
23
- authenticatedUser.userType = authenticatedUser.org ? "org" : "customer";
24
- return authenticatedUser;
25
- };
26
- exports.whoAmI = whoAmI;
package/lib/yeoman.js DELETED
@@ -1,27 +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.runGenerator = void 0;
7
- const yeoman_environment_1 = __importDefault(require("yeoman-environment"));
8
- // TODO: Derive this from the generator package
9
- const generatorTypes = [
10
- "component",
11
- "action",
12
- "trigger",
13
- "dataSource",
14
- "connection",
15
- "formats",
16
- "integration",
17
- "flow",
18
- ];
19
- const runGenerator = async (generatorName, options) => {
20
- if (!generatorTypes.includes(generatorName)) {
21
- throw new Error(`Invalid generator type specified: ${generatorName}`);
22
- }
23
- const env = yeoman_environment_1.default.createEnv();
24
- env.register(require.resolve(`@prismatic-io/generator-spectral/generators/${generatorName}`), generatorName);
25
- await env.run(generatorName, options);
26
- };
27
- exports.runGenerator = runGenerator;
File without changes