@prismatic-io/prism 5.2.11 → 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,247 +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.uploadConnectionIcons = exports.uploadFile = exports.publishDefinition = exports.confirmPublish = exports.checkPackageSignature = exports.createComponentPackage = exports.validateDefinition = exports.loadEntrypoint = void 0;
7
- const core_1 = require("@oclif/core");
8
- const fs_1 = require("../../fs");
9
- const path_1 = require("path");
10
- const tempy_1 = __importDefault(require("tempy"));
11
- const crypto_1 = __importDefault(require("crypto"));
12
- const archiver_1 = __importDefault(require("archiver"));
13
- const graphql_1 = require("../../graphql");
14
- const import_1 = require("../import");
15
- const axios_1 = __importDefault(require("axios"));
16
- const mime_types_1 = __importDefault(require("mime-types"));
17
- const componentDefinitionShape = {
18
- actions: true,
19
- authorization: true,
20
- connections: true,
21
- dataSources: true,
22
- display: true,
23
- documentationUrl: true,
24
- key: true,
25
- public: true,
26
- triggers: true,
27
- };
28
- const loadEntrypoint = async () => {
29
- // If we don't have an index.js in cwd seek directories to find package.json of component
30
- if (!(await (0, fs_1.exists)("index.js"))) {
31
- await (0, import_1.seekPackageDistDirectory)("component");
32
- }
33
- // If we still didn't find index.js error out
34
- if (!(await (0, fs_1.exists)("index.js"))) {
35
- core_1.ux.error("Failed to find 'index.js' entrypoint file. Is the current path a component?", { exit: 1 });
36
- }
37
- // Require index.js and access its root-most default export which should be the Component config
38
- const cwd = process.cwd();
39
- const entrypointPath = (0, path_1.resolve)(cwd, "./index.js");
40
- const { default: definition } = require(entrypointPath); // eslint-disable-line @typescript-eslint/no-var-requires
41
- return definition;
42
- };
43
- exports.loadEntrypoint = loadEntrypoint;
44
- const validateIcon = async (iconPath) => !iconPath ||
45
- ((0, path_1.extname)(iconPath.trim().toLowerCase()) === ".png" &&
46
- (await (0, fs_1.exists)(iconPath)));
47
- const validateDefinition = async (definition) => {
48
- // Output basic information to the user to confirm that this component is what they want to publish
49
- const { display: { label, description, iconPath }, connections, } = definition;
50
- if (!label || !description) {
51
- core_1.ux.error("Missing required values `label` or `description`. Exiting.", {
52
- exit: 1,
53
- });
54
- }
55
- const componentIconValid = await validateIcon(iconPath);
56
- if (!componentIconValid) {
57
- core_1.ux.error(`Component icon does not exist or is not a png. Exiting.`, {
58
- exit: 1,
59
- });
60
- }
61
- const connectionIconsValid = await Promise.all((connections !== null && connections !== void 0 ? connections : []).map(({ iconPath }) => validateIcon(iconPath)));
62
- if (connectionIconsValid.some((v) => !v)) {
63
- core_1.ux.error(`One or more connection icons do not exist or are not a png. Exiting.`, {
64
- exit: 1,
65
- });
66
- }
67
- };
68
- exports.validateDefinition = validateDefinition;
69
- const createComponentPackage = async () => {
70
- const zip = (0, archiver_1.default)("zip", { zlib: { level: 9 } });
71
- const pathPromise = tempy_1.default.write(zip, { extension: "zip" });
72
- // Zip all files in the current directory (since we found the index.js entrypoint)
73
- // Set all files' dates to the Unix epoch so that the zip hash is deterministic
74
- zip.directory(process.cwd(), false, (entry) => ({
75
- ...entry,
76
- date: new Date(0),
77
- }));
78
- await zip.finalize();
79
- return pathPromise;
80
- };
81
- exports.createComponentPackage = createComponentPackage;
82
- const checkPackageSignature = async ({ key, public: isPublic }, packagePath, customer) => {
83
- // Retrieve the existing signature of the component if it exists.
84
- const results = await (0, graphql_1.gqlRequest)({
85
- document: (0, graphql_1.gql) `
86
- query component($key: String!, $public: Boolean!, $customer: ID) {
87
- components(key: $key, public: $public, customer: $customer) {
88
- nodes {
89
- signature
90
- }
91
- }
92
- }
93
- `,
94
- variables: {
95
- key,
96
- public: isPublic !== null && isPublic !== void 0 ? isPublic : false,
97
- customer,
98
- },
99
- });
100
- const { components: { nodes: [{ signature: existingSignature } = { signature: null }], }, } = results;
101
- // Generate the signature of the package so we may compare it against the existing one.
102
- const packageSignature = crypto_1.default
103
- .createHash("sha1")
104
- .update(await fs_1.fs.readFile(packagePath))
105
- .digest("hex");
106
- return existingSignature === packageSignature;
107
- };
108
- exports.checkPackageSignature = checkPackageSignature;
109
- const confirmPublish = async ({ display: { label, description } }, confirm = true) => {
110
- if (!confirm)
111
- return;
112
- core_1.ux.log(label, "-", description);
113
- const continuePublish = await core_1.ux.confirm(`Would you like to publish ${label}? (y/N)`);
114
- if (!continuePublish)
115
- core_1.ux.exit(0);
116
- };
117
- exports.confirmPublish = confirmPublish;
118
- const publishDefinition = async ({ actions, triggers, dataSources, connections, ...rest }, comment, customer, forCodeNativeIntegration) => {
119
- const componentDefinition = Object.entries(rest).reduce((result, [key, value]) => componentDefinitionShape[key]
120
- ? { ...result, [key]: value }
121
- : result, {});
122
- componentDefinition.forCodeNativeIntegration = forCodeNativeIntegration;
123
- const actionDefinitions = Object.values(actions || {}).map((action) => {
124
- return {
125
- ...action,
126
- examplePayload: (action === null || action === void 0 ? void 0 : action.examplePayload)
127
- ? JSON.stringify(action === null || action === void 0 ? void 0 : action.examplePayload)
128
- : JSON.stringify({}),
129
- };
130
- });
131
- const triggerDefinitions = Object.values(triggers || {}).map((trigger) => {
132
- return {
133
- ...trigger,
134
- examplePayload: (trigger === null || trigger === void 0 ? void 0 : trigger.examplePayload)
135
- ? JSON.stringify(trigger === null || trigger === void 0 ? void 0 : trigger.examplePayload)
136
- : JSON.stringify({}),
137
- };
138
- });
139
- const dataSourceDefinitions = Object.values(dataSources || {}).map((dataSource) => {
140
- return {
141
- ...dataSource,
142
- examplePayload: (dataSource === null || dataSource === void 0 ? void 0 : dataSource.examplePayload)
143
- ? JSON.stringify(dataSource === null || dataSource === void 0 ? void 0 : dataSource.examplePayload)
144
- : JSON.stringify({}),
145
- };
146
- });
147
- const connectionDefinitions = connections || [];
148
- // Initiate start of the publish procedure by sending config data and receive back presigned s3 URL
149
- const result = await (0, graphql_1.gqlRequest)({
150
- document: (0, graphql_1.gql) `
151
- mutation publishComponent(
152
- $definition: ComponentDefinitionInput!
153
- $actions: [ActionDefinitionInput]!
154
- $triggers: [TriggerDefinitionInput]
155
- $dataSources: [DataSourceDefinitionInput]
156
- $connections: [ConnectionDefinitionInput]
157
- $comment: String
158
- $customer: ID
159
- ) {
160
- publishComponent(
161
- input: {
162
- definition: $definition
163
- actions: $actions
164
- triggers: $triggers
165
- dataSources: $dataSources
166
- connections: $connections
167
- comment: $comment
168
- customer: $customer
169
- }
170
- ) {
171
- publishResult {
172
- component {
173
- id
174
- versionNumber
175
- }
176
- iconUploadUrl
177
- packageUploadUrl
178
- connectionIconUploadUrls {
179
- connectionKey
180
- iconUploadUrl
181
- }
182
- }
183
- errors {
184
- field
185
- messages
186
- }
187
- }
188
- }
189
- `,
190
- variables: {
191
- definition: componentDefinition,
192
- actions: actionDefinitions,
193
- triggers: triggerDefinitions,
194
- dataSources: dataSourceDefinitions,
195
- connections: connectionDefinitions,
196
- comment,
197
- customer,
198
- },
199
- });
200
- const { iconUploadUrl, packageUploadUrl, connectionIconUploadUrls, component: { versionNumber }, } = result.publishComponent.publishResult;
201
- const uploadUrls = connectionIconUploadUrls.reduce((result, { connectionKey, iconUploadUrl }) => ({
202
- ...result,
203
- [connectionKey]: iconUploadUrl,
204
- }), {});
205
- return {
206
- iconUploadUrl,
207
- packageUploadUrl,
208
- connectionIconUploadUrls: uploadUrls,
209
- versionNumber,
210
- };
211
- };
212
- exports.publishDefinition = publishDefinition;
213
- const uploadFile = async (filePath, destinationUrl) => {
214
- try {
215
- // TODO: Stream instead of Buffer.
216
- const response = await axios_1.default.put(destinationUrl, await fs_1.fs.readFile(filePath), { headers: { "Content-Type": mime_types_1.default.contentType((0, path_1.extname)(filePath)) } });
217
- return response;
218
- }
219
- catch (error) {
220
- if (axios_1.default.isAxiosError(error)) {
221
- const { message } = error;
222
- throw new Error(message);
223
- }
224
- throw error;
225
- }
226
- };
227
- exports.uploadFile = uploadFile;
228
- const uploadConnectionIcons = async ({ connections }, connectionIconUploadUrls) => {
229
- if (!connections ||
230
- !connections.length ||
231
- !connectionIconUploadUrls ||
232
- !Object.keys(connectionIconUploadUrls).length) {
233
- return;
234
- }
235
- const iconPaths = connections.reduce((result, { key, iconPath }) => {
236
- if (!iconPath) {
237
- return result;
238
- }
239
- return {
240
- ...result,
241
- [key]: iconPath,
242
- };
243
- }, {});
244
- const promises = Object.entries(connectionIconUploadUrls).map(async ([connectionKey, uploadUrl]) => (0, exports.uploadFile)(iconPaths[connectionKey], uploadUrl));
245
- await Promise.all(promises);
246
- };
247
- exports.uploadConnectionIcons = uploadConnectionIcons;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryComponentKeys = void 0;
4
- const graphql_1 = require("../../graphql");
5
- const queryComponentKeys = async (keys) => {
6
- const result = await (0, graphql_1.gqlRequest)({
7
- document: (0, graphql_1.gql) `
8
- query components($keys: [String]!) {
9
- components(key_In: $keys) {
10
- nodes {
11
- id
12
- key
13
- versionNumber
14
- public
15
- }
16
- }
17
- }
18
- `,
19
- variables: { keys },
20
- });
21
- return result.components.nodes;
22
- };
23
- exports.queryComponentKeys = queryComponentKeys;
package/lib/utils/date.js DELETED
@@ -1,14 +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.formatTimestamp = void 0;
7
- const dayjs_1 = __importDefault(require("dayjs"));
8
- const utc_1 = __importDefault(require("dayjs/plugin/utc"));
9
- const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
10
- dayjs_1.default.extend(utc_1.default);
11
- dayjs_1.default.extend(timezone_1.default);
12
- const formatTimestamp = (timestamp) => (0, dayjs_1.default)(timestamp, "YYYY-MM-DDTHH:mm:ss.SSS000+Z", true).format("HH:mm:ss.SSS");
13
- exports.formatTimestamp = formatTimestamp;
14
- exports.default = dayjs_1.default;
@@ -1,86 +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.displayLogs = exports.waitForExecutionCompletion = void 0;
7
- const core_1 = require("@oclif/core");
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const date_1 = require("../date");
10
- const graphql_1 = require("../../graphql");
11
- const util_1 = require("util");
12
- const setTimeoutPromise = (0, util_1.promisify)(setTimeout);
13
- const waitForExecutionCompletion = (executionId) => {
14
- return new Promise((resolve, reject) => {
15
- const interval = setInterval(async () => {
16
- try {
17
- const result = await (0, graphql_1.gqlRequest)({
18
- document: (0, graphql_1.gql) `
19
- query pollExecution($executionId: ID!) {
20
- executionResult(id: $executionId) {
21
- endedAt
22
- }
23
- }
24
- `,
25
- variables: { executionId },
26
- });
27
- const { endedAt } = result.executionResult;
28
- if (endedAt) {
29
- clearInterval(interval);
30
- // Grace period to let logs finish flowing; logs are fully async and are
31
- // not guaranteed to be added in chronological order.
32
- await setTimeoutPromise(2000);
33
- resolve();
34
- }
35
- }
36
- catch (error) {
37
- clearInterval(interval);
38
- reject(error);
39
- }
40
- }, 1000);
41
- });
42
- };
43
- exports.waitForExecutionCompletion = waitForExecutionCompletion;
44
- const displayLogs = async (executionId) => {
45
- await (0, exports.waitForExecutionCompletion)(executionId);
46
- // TODO: Add paging
47
- const result = await (0, graphql_1.gqlRequest)({
48
- document: (0, graphql_1.gql) `
49
- query logs($executionId: ID!) {
50
- executionResult(id: $executionId) {
51
- logs(orderBy: { field: TIMESTAMP, direction: ASC }) {
52
- nodes {
53
- timestamp
54
- severity
55
- message
56
- }
57
- }
58
- }
59
- }
60
- `,
61
- variables: { executionId },
62
- });
63
- const logs = result.executionResult.logs.nodes;
64
- core_1.ux.table(logs, {
65
- timestamp: {
66
- get: ({ timestamp }) => (0, date_1.formatTimestamp)(timestamp),
67
- },
68
- severity: {
69
- minWidth: 12,
70
- get: ({ severity }) => {
71
- if (severity == "INFO") {
72
- return chalk_1.default.blue("info");
73
- }
74
- if (severity == "WARN") {
75
- return chalk_1.default.yellow("warn");
76
- }
77
- if (severity == "ERROR") {
78
- return chalk_1.default.red("error");
79
- }
80
- return severity.toLowerCase();
81
- },
82
- },
83
- message: {},
84
- }, { "no-header": true });
85
- };
86
- exports.displayLogs = displayLogs;
@@ -1,87 +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.printFinalStepResults = exports.writeFinalStepResults = exports.parseData = exports.deserialize = void 0;
7
- const msgpack_1 = require("@msgpack/msgpack");
8
- const axios_1 = __importDefault(require("axios"));
9
- const fs_1 = require("../../fs");
10
- const graphql_1 = require("../../graphql");
11
- const mime_types_1 = require("mime-types");
12
- const deserialize = (data) => (0, msgpack_1.decode)(data);
13
- exports.deserialize = deserialize;
14
- const parseData = (data, contentType = "") => {
15
- if (data === null || data === undefined) {
16
- return "";
17
- }
18
- // Some content-types require additional processing.
19
- const dataType = (0, mime_types_1.extension)(contentType);
20
- if (contentType.startsWith("text/") ||
21
- (dataType && ["json", "xml", "csv", "xhtml"].includes(dataType))) {
22
- // If the content-types specifies that the data is text/, or if the extension
23
- // is a well-known text-like type, convert the data to a string.
24
- if (dataType === "json") {
25
- try {
26
- // If the payload is supposed to be JSON, ensure that it can be parsed.
27
- return JSON.parse(data.toString());
28
- }
29
- catch {
30
- throw new Error("Received malformed JSON payload.");
31
- }
32
- }
33
- return data;
34
- }
35
- else if (contentType.startsWith("binary/")) {
36
- return data;
37
- }
38
- return typeof data === "string" ||
39
- (typeof data === "object" && Buffer.isBuffer(data))
40
- ? data
41
- : JSON.stringify(data);
42
- };
43
- exports.parseData = parseData;
44
- const getFinalStepResult = async (executionId) => {
45
- const result = await (0, graphql_1.gqlRequest)({
46
- document: (0, graphql_1.gql) `
47
- query executionResults($executionId: ID!) {
48
- executionResult(id: $executionId) {
49
- stepResults(last: 1) {
50
- nodes {
51
- id
52
- stepName
53
- resultsUrl
54
- }
55
- }
56
- }
57
- }
58
- `,
59
- variables: { executionId },
60
- });
61
- const { resultsUrl } = result.executionResult.stepResults.nodes[0];
62
- const response = await axios_1.default.get(resultsUrl, {
63
- responseType: "arraybuffer",
64
- });
65
- const resultsBuffer = Buffer.from(await response.data);
66
- const { data: deserializedResult, contentType } = (0, msgpack_1.decode)(resultsBuffer);
67
- return {
68
- data: (0, exports.parseData)(deserializedResult, contentType),
69
- contentType,
70
- };
71
- };
72
- const writeFinalStepResults = async (executionId, fileName) => {
73
- const result = await getFinalStepResult(executionId);
74
- await fs_1.fs.writeFile(fileName, result.data);
75
- };
76
- exports.writeFinalStepResults = writeFinalStepResults;
77
- const printFinalStepResults = async (executionId) => {
78
- const result = await getFinalStepResult(executionId);
79
- console.log(`
80
- ======== Step Results ========
81
-
82
- ${result.data}
83
-
84
- ==============================
85
- `);
86
- };
87
- exports.printFinalStepResults = printFinalStepResults;
@@ -1,50 +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.formatSourceFiles = exports.getFilesToFormat = exports.VALID_NAME_REGEX = void 0;
30
- const prettier_1 = __importDefault(require("prettier"));
31
- const glob_promise_1 = __importDefault(require("glob-promise"));
32
- const fs_1 = require("fs");
33
- const path = __importStar(require("path"));
34
- exports.VALID_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$/;
35
- const getFilesToFormat = async (basename) => {
36
- return await (0, glob_promise_1.default)("**/*.ts", {
37
- ignore: ["**/node_modules/**"],
38
- cwd: path.dirname(basename),
39
- });
40
- };
41
- exports.getFilesToFormat = getFilesToFormat;
42
- const formatSourceFiles = async (basePath, files) => {
43
- //format the text of each file
44
- await Promise.all(files.map(async (filePath) => {
45
- const formattedFile = prettier_1.default.format(await fs_1.promises.readFile(path.resolve(path.dirname(basePath), filePath), "utf-8"), { parser: "typescript" });
46
- //write the formatted text to the proper file location
47
- await fs_1.promises.writeFile(path.resolve(path.dirname(basePath), filePath), formattedFile);
48
- }));
49
- };
50
- exports.formatSourceFiles = formatSourceFiles;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.seekPackageDistDirectory = void 0;
4
- const core_1 = require("@oclif/core");
5
- const fs_1 = require("../fs");
6
- const seekPackageDistDirectory = async (packageType) => {
7
- while (!(await (0, fs_1.exists)("package.json"))) {
8
- const tempDir = process.cwd();
9
- process.chdir("../");
10
- if (process.cwd() == tempDir) {
11
- core_1.ux.error(`Failed to find 'package.json' file. Is the current path a ${packageType}?`, { exit: 1 });
12
- }
13
- }
14
- if (!(await (0, fs_1.exists)("./dist"))) {
15
- core_1.ux.error(`Failed to find 'dist' folder. Is the current path a ${packageType}?`, {
16
- exit: 1,
17
- });
18
- }
19
- process.chdir("./dist");
20
- };
21
- exports.seekPackageDistDirectory = seekPackageDistDirectory;
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildComponentTestHarnessIntegration = exports.defaultDefinition = exports.buildStep = exports.buildConnectionConfigVar = exports.componentTestIntegrationName = void 0;
4
- const serialize_1 = require("../serialize");
5
- const lodash_1 = require("lodash");
6
- const export_1 = require("./export");
7
- const componentTestIntegrationName = (componentKey, name) => `Component Test Harness - ${componentKey} - ${name}`;
8
- exports.componentTestIntegrationName = componentTestIntegrationName;
9
- const buildConnectionConfigVar = ({ key: componentKey, isPublic }, { key, values }) => {
10
- return {
11
- key: "testConnection",
12
- description: "Test Connection",
13
- dataType: "connection",
14
- connection: {
15
- component: {
16
- key: componentKey,
17
- isPublic,
18
- version: "LATEST",
19
- },
20
- key,
21
- },
22
- inputs: values,
23
- };
24
- };
25
- exports.buildConnectionConfigVar = buildConnectionConfigVar;
26
- const buildStep = ({ key: componentKey, isPublic }, { key, values }) => {
27
- return {
28
- name: "Test Step",
29
- action: {
30
- component: {
31
- key: componentKey,
32
- isPublic,
33
- version: "LATEST",
34
- },
35
- key,
36
- },
37
- inputs: values,
38
- };
39
- };
40
- exports.buildStep = buildStep;
41
- const defaultDefinition = ({ integrationInfo: { name: integrationName }, componentInfo, actionInfo, connectionInfo, }) => {
42
- const requiredConfigVars = connectionInfo
43
- ? [(0, exports.buildConnectionConfigVar)(componentInfo, connectionInfo)]
44
- : [];
45
- const { key: componentKey } = componentInfo;
46
- const definition = {
47
- definitionVersion: 6,
48
- name: integrationName,
49
- description: `Test Harness for the ${componentKey} Component`,
50
- category: "Component Development",
51
- requiredConfigVars,
52
- flows: [
53
- {
54
- name: "Flow 1",
55
- steps: [
56
- {
57
- name: "Trigger",
58
- isTrigger: true,
59
- action: {
60
- component: {
61
- key: "webhook-triggers",
62
- isPublic: true,
63
- version: "LATEST",
64
- },
65
- key: "webhook",
66
- },
67
- },
68
- (0, exports.buildStep)(componentInfo, actionInfo),
69
- ],
70
- },
71
- ],
72
- };
73
- return definition;
74
- };
75
- exports.defaultDefinition = defaultDefinition;
76
- const buildComponentTestHarnessIntegration = async (info) => {
77
- var _a, _b;
78
- const { integrationInfo: { id: integrationId }, componentInfo, actionInfo, connectionInfo, } = info;
79
- const definition = integrationId
80
- ? await (0, export_1.exportDefinition)({ integrationId })
81
- : (0, exports.defaultDefinition)(info);
82
- // Update "current definition" accordingly.
83
- if (connectionInfo) {
84
- const connection = (0, exports.buildConnectionConfigVar)(componentInfo, connectionInfo);
85
- const existingConnection = (_b = (_a = definition.requiredConfigVars) === null || _a === void 0 ? void 0 : _a.filter(({ key }) => key === "testConnection")) === null || _b === void 0 ? void 0 : _b[0];
86
- if (existingConnection) {
87
- (0, lodash_1.merge)(existingConnection, connection);
88
- }
89
- else if (definition.requiredConfigVars) {
90
- definition.requiredConfigVars.push(connection);
91
- }
92
- else {
93
- definition.requiredConfigVars = [connection];
94
- }
95
- }
96
- const step = (0, exports.buildStep)(componentInfo, actionInfo);
97
- const existingStep = definition.flows[0].steps.filter(({ name }) => name === "Test Step")[0];
98
- (0, lodash_1.merge)(existingStep, step);
99
- return (0, serialize_1.dumpYaml)(definition);
100
- };
101
- exports.buildComponentTestHarnessIntegration = buildComponentTestHarnessIntegration;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exportDefinition = exports.INTEGRATION_DEFINITION_VERSION = void 0;
4
- const graphql_1 = require("../../graphql");
5
- const serialize_1 = require("../serialize");
6
- /** The version of the Integration definition to request.
7
- * It's important to request a version that corresponds with the
8
- * feature set in this version.
9
- */
10
- exports.INTEGRATION_DEFINITION_VERSION = 7;
11
- const exportDefinition = async ({ integrationId, latestComponents = false, definitionVersion = exports.INTEGRATION_DEFINITION_VERSION, }) => {
12
- const result = await (0, graphql_1.gqlRequest)({
13
- document: (0, graphql_1.gql) `
14
- query export(
15
- $id: ID!
16
- $version: Int!
17
- $useLatestComponentVersions: Boolean!
18
- ) {
19
- integration(id: $id) {
20
- definition(
21
- version: $version
22
- useLatestComponentVersions: $useLatestComponentVersions
23
- )
24
- }
25
- }
26
- `,
27
- variables: {
28
- id: integrationId,
29
- version: definitionVersion,
30
- useLatestComponentVersions: latestComponents,
31
- },
32
- });
33
- const definition = result.integration.definition;
34
- return (0, serialize_1.loadYaml)(definition);
35
- };
36
- exports.exportDefinition = exportDefinition;