@prismatic-io/prism 4.10.0 → 5.0.0-preview2

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.
@@ -22,9 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  const core_1 = require("@oclif/core");
30
27
  const fs_1 = require("fs");
@@ -32,24 +29,8 @@ const path = __importStar(require("path"));
32
29
  const wsdl_tsclient_1 = require("wsdl-tsclient");
33
30
  const logger_1 = require("wsdl-tsclient/dist/src/utils/logger");
34
31
  const index_1 = require("../../../generate/index");
35
- const prettier_1 = __importDefault(require("prettier"));
36
- const glob_promise_1 = __importDefault(require("glob-promise"));
37
32
  const yeoman_1 = require("../../../yeoman");
38
- const componentNameRegex = /^[a-zA-Z0-9][a-zA-Z0-9-_]*[a-zA-Z0-9]$/;
39
- const getFilesToFormat = async (basename) => {
40
- return await (0, glob_promise_1.default)("**/*.ts", {
41
- ignore: ["**/node_modules/**"],
42
- cwd: path.dirname(basename),
43
- });
44
- };
45
- const formatSourceFiles = async (basePath, files) => {
46
- //format the text of each file
47
- await Promise.all(files.map(async (filePath) => {
48
- const formattedFile = prettier_1.default.format(await fs_1.promises.readFile(path.resolve(path.dirname(basePath), filePath), "utf-8"), { parser: "typescript" });
49
- //write the formatted text to the proper file location
50
- await fs_1.promises.writeFile(path.resolve(path.dirname(basePath), filePath), formattedFile);
51
- }));
52
- };
33
+ const generate_1 = require("../../../utils/generate");
53
34
  class InitializeComponent extends core_1.Command {
54
35
  async run() {
55
36
  const { args: { name }, flags: { verbose, "wsdl-path": rawWsdlPath, "open-api-path": rawOpenApiPath, }, } = await this.parse(InitializeComponent);
@@ -57,8 +38,8 @@ class InitializeComponent extends core_1.Command {
57
38
  const openApiPath = rawOpenApiPath
58
39
  ? path.resolve(rawOpenApiPath)
59
40
  : undefined;
60
- if (!componentNameRegex.test(name)) {
61
- this.error(`'${name}' contains invalid characters. Please select a component name that starts and ends with alphanumeric characters, and contains only alphanumeric characters, hyphens, and underscores. See https://regex101.com/?regex=${encodeURIComponent(componentNameRegex.source)}`, { exit: 1 });
41
+ if (!generate_1.VALID_NAME_REGEX.test(name)) {
42
+ this.error(`'${name}' contains invalid characters. Please select a component name that starts and ends with alphanumeric characters, and contains only alphanumeric characters, hyphens, and underscores. See https://regex101.com/?regex=${encodeURIComponent(generate_1.VALID_NAME_REGEX.source)}`, { exit: 1 });
62
43
  }
63
44
  if (wsdlPath && !(wsdlPath === null || wsdlPath === void 0 ? void 0 : wsdlPath.includes(".wsdl"))) {
64
45
  this.error("If a WSDL is provided it must have an extension of '.wsdl'", {
@@ -105,8 +86,8 @@ class InitializeComponent extends core_1.Command {
105
86
  path: path.resolve(name, "package.json"),
106
87
  dependencies: { soap: "0.40.0" },
107
88
  });
108
- const filesToFormat = await getFilesToFormat(name);
109
- await formatSourceFiles(name, filesToFormat);
89
+ const filesToFormat = await (0, generate_1.getFilesToFormat)(name);
90
+ await (0, generate_1.formatSourceFiles)(name, filesToFormat);
110
91
  }
111
92
  this.log(`
112
93
  "${name}" is ready for development.
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const chardet_1 = __importDefault(require("chardet"));
7
3
  const core_1 = require("@oclif/core");
8
4
  const fs_1 = require("../../fs");
9
- const graphql_1 = require("../../graphql");
10
- const avatar_1 = require("../../utils/avatar");
11
5
  const import_1 = require("../../utils/integration/import");
6
+ const open_1 = require("../../utils/integration/open");
12
7
  class ImportCommand extends core_1.Command {
13
8
  async run() {
14
- const { flags: { path, integrationId, "icon-path": iconPath }, } = await this.parse(ImportCommand);
15
- if (!(await (0, fs_1.exists)(path))) {
9
+ const { flags: { path, integrationId, "icon-path": iconPath, open }, } = await this.parse(ImportCommand);
10
+ if (path && !(await (0, fs_1.exists)(path))) {
16
11
  this.error(`Cannot find definition file at specified path "${path}"`, {
17
12
  exit: 2,
18
13
  });
@@ -22,51 +17,24 @@ class ImportCommand extends core_1.Command {
22
17
  exit: 2,
23
18
  });
24
19
  }
25
- const encoding = await chardet_1.default.detectFile(path);
26
- const definition = await fs_1.fs.readFile(path, encoding === "UTF-16LE" ? "utf16le" : "utf-8");
27
- const { integrationId: integrationImportId } = await (0, import_1.importDefinition)(definition, integrationId);
28
- if (iconPath) {
29
- try {
30
- const avatarUrl = await (0, avatar_1.uploadAvatar)(integrationImportId, iconPath);
31
- await (0, graphql_1.gqlRequest)({
32
- document: (0, graphql_1.gql) `
33
- mutation commitAvatarUpload(
34
- $integrationId: ID!
35
- $avatarUrl: String!
36
- ) {
37
- updateIntegration(
38
- input: { id: $integrationId, avatarUrl: $avatarUrl }
39
- ) {
40
- integration {
41
- id
42
- }
43
- errors {
44
- field
45
- messages
46
- }
47
- }
48
- }
49
- `,
50
- variables: {
51
- integrationId: integrationImportId,
52
- avatarUrl,
53
- },
54
- });
55
- }
56
- catch (err) {
57
- console.warn(`Error setting integration icon: ${err}`);
58
- }
59
- }
20
+ const integrationImportId = path
21
+ ? // A path was specified, so assume we're importing a YAML Integration.
22
+ await (0, import_1.importYamlIntegration)(path, integrationId)
23
+ : // No path was specified, so assume the current directory is a Code Native Integration and import it.
24
+ await (0, import_1.importCodeNativeIntegration)(integrationId);
60
25
  this.log(integrationImportId);
26
+ if (open) {
27
+ await (0, open_1.openIntegration)(integrationImportId);
28
+ }
61
29
  }
62
30
  }
63
31
  exports.default = ImportCommand;
64
- ImportCommand.description = "Import an Integration using a YAML definition file";
32
+ ImportCommand.description = "Import an Integration using a YAML definition file or a Code Native Integration";
65
33
  ImportCommand.flags = {
66
34
  path: core_1.Flags.string({
67
35
  char: "p",
68
- required: true,
69
- description: "path to the YAML definition of the integration to import",
36
+ required: false,
37
+ description: "If supplied, the path to the YAML definition of the integration to import. Not applicable for Code Native Integrations.",
70
38
  }),
71
39
  integrationId: core_1.Flags.string({
72
40
  char: "i",
@@ -75,6 +43,12 @@ ImportCommand.flags = {
75
43
  }),
76
44
  "icon-path": core_1.Flags.string({
77
45
  required: false,
78
- description: "path to the PNG icon for the integration",
46
+ description: "If supplied, the path to the PNG icon for the integration. Not applicable for Code Native Integrations.",
47
+ }),
48
+ open: core_1.Flags.boolean({
49
+ char: "o",
50
+ required: false,
51
+ default: false,
52
+ description: "If supplied, open the Designer for the imported integration",
79
53
  }),
80
54
  };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const yeoman_1 = require("../../../yeoman");
5
+ class GenerateFlowCommand extends core_1.Command {
6
+ async run() {
7
+ await this.parse(GenerateFlowCommand);
8
+ await (0, yeoman_1.runGenerator)("flow");
9
+ }
10
+ }
11
+ exports.default = GenerateFlowCommand;
12
+ GenerateFlowCommand.description = "Initialize a new file for a Code Native Integration Flow";
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const fs_1 = require("fs");
5
+ const yeoman_1 = require("../../../yeoman");
6
+ const generate_1 = require("../../../utils/generate");
7
+ class InitializeIntegration extends core_1.Command {
8
+ async run() {
9
+ const { args: { name }, } = await this.parse(InitializeIntegration);
10
+ if (!generate_1.VALID_NAME_REGEX.test(name)) {
11
+ this.error(`'${name}' contains invalid characters. Please select an integration name that starts and ends with alphanumeric characters, and contains only alphanumeric characters, hyphens, and underscores. See https://regex101.com/?regex=${encodeURIComponent(generate_1.VALID_NAME_REGEX.source)}`, { exit: 1 });
12
+ }
13
+ this.log(`Creating directory for "${name}"...`);
14
+ await fs_1.promises.mkdir(name);
15
+ const cwd = process.cwd();
16
+ process.chdir(name);
17
+ // Legacy code paths (mostly; keep the component generator call)
18
+ await (0, yeoman_1.runGenerator)("integration", process.env.NODE_ENV === "test"
19
+ ? {
20
+ name,
21
+ description: "Prism-generated Integration",
22
+ skipInstall: true,
23
+ }
24
+ : { name, skipInstall: false });
25
+ // Pop back out.
26
+ process.chdir(cwd);
27
+ this.log(`
28
+ "${name}" is ready for development.
29
+ To install dependencies, run either "npm install" or "yarn install"
30
+ To run unit tests for the integration, run "npm run test" or "yarn test"
31
+ To build the integration, run "npm run build" or "yarn build"
32
+ To import the integration, run "prism integrations:import"
33
+
34
+ For documentation on writing Code Native Integrations, visit https://prismatic.io/docs/code-native-integrations/
35
+ `);
36
+ }
37
+ }
38
+ exports.default = InitializeIntegration;
39
+ InitializeIntegration.description = "Initialize a new Code Native Integration";
40
+ InitializeIntegration.args = {
41
+ name: core_1.Args.string({
42
+ required: true,
43
+ description: "Name of the new integration to create (alphanumeric characters, hyphens, and underscores)",
44
+ }),
45
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const yeoman_1 = require("../../../yeoman");
5
+ class GenerateIntegrationCommand extends core_1.Command {
6
+ async run() {
7
+ await this.parse(GenerateIntegrationCommand);
8
+ await (0, yeoman_1.runGenerator)("integration");
9
+ }
10
+ }
11
+ exports.default = GenerateIntegrationCommand;
12
+ GenerateIntegrationCommand.description = "Initialize a new Code Native Integration";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const open_1 = require("../../utils/integration/open");
5
+ class OpenCommand extends core_1.Command {
6
+ async run() {
7
+ const { args: { integrationId }, } = await this.parse(OpenCommand);
8
+ await (0, open_1.openIntegration)(integrationId);
9
+ }
10
+ }
11
+ exports.default = OpenCommand;
12
+ OpenCommand.description = "Open the Designer for the specified Integration";
13
+ OpenCommand.args = {
14
+ integrationId: core_1.Args.string({
15
+ required: true,
16
+ description: "ID of the integration to open",
17
+ }),
18
+ };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.uploadConnectionIcons = exports.uploadFile = exports.publishDefinition = exports.confirmPublish = exports.checkPackageSignature = exports.createComponentPackage = exports.validateDefinition = exports.loadEntrypoint = exports.seekComponentPackageDistDirectory = void 0;
6
+ exports.uploadConnectionIcons = exports.uploadFile = exports.publishDefinition = exports.confirmPublish = exports.checkPackageSignature = exports.createComponentPackage = exports.validateDefinition = exports.loadEntrypoint = void 0;
7
7
  const core_1 = require("@oclif/core");
8
8
  const fs_1 = require("../../fs");
9
9
  const path_1 = require("path");
@@ -11,6 +11,7 @@ const tempy_1 = __importDefault(require("tempy"));
11
11
  const crypto_1 = __importDefault(require("crypto"));
12
12
  const archiver_1 = __importDefault(require("archiver"));
13
13
  const graphql_1 = require("../../graphql");
14
+ const import_1 = require("../import");
14
15
  const axios_1 = __importDefault(require("axios"));
15
16
  const mime_types_1 = __importDefault(require("mime-types"));
16
17
  const componentDefinitionShape = {
@@ -24,26 +25,10 @@ const componentDefinitionShape = {
24
25
  public: true,
25
26
  triggers: true,
26
27
  };
27
- const seekComponentPackageDistDirectory = async () => {
28
- while (!(await (0, fs_1.exists)("package.json"))) {
29
- const tempDir = process.cwd();
30
- process.chdir("../");
31
- if (process.cwd() == tempDir) {
32
- core_1.ux.error("Failed to find 'package.json' file. Is the current path a component?", { exit: 1 });
33
- }
34
- }
35
- if (!(await (0, fs_1.exists)("./dist"))) {
36
- core_1.ux.error("Failed to find 'dist' folder. Is the current path a component?", {
37
- exit: 1,
38
- });
39
- }
40
- process.chdir("./dist");
41
- };
42
- exports.seekComponentPackageDistDirectory = seekComponentPackageDistDirectory;
43
28
  const loadEntrypoint = async () => {
44
29
  // If we don't have an index.js in cwd seek directories to find package.json of component
45
30
  if (!(await (0, fs_1.exists)("index.js"))) {
46
- await (0, exports.seekComponentPackageDistDirectory)();
31
+ await (0, import_1.seekPackageDistDirectory)("component");
47
32
  }
48
33
  // If we still didn't find index.js error out
49
34
  if (!(await (0, fs_1.exists)("index.js"))) {
@@ -126,10 +111,11 @@ const confirmPublish = async ({ display: { label, description } }, confirm = tru
126
111
  core_1.ux.exit(0);
127
112
  };
128
113
  exports.confirmPublish = confirmPublish;
129
- const publishDefinition = async ({ actions, triggers, dataSources, connections, ...rest }, comment, customer) => {
114
+ const publishDefinition = async ({ actions, triggers, dataSources, connections, ...rest }, comment, customer, forCodeNativeIntegration) => {
130
115
  const componentDefinition = Object.entries(rest).reduce((result, [key, value]) => componentDefinitionShape[key]
131
116
  ? { ...result, [key]: value }
132
117
  : result, {});
118
+ componentDefinition.forCodeNativeIntegration = forCodeNativeIntegration;
133
119
  const actionDefinitions = Object.values(actions || {}).map((action) => {
134
120
  return {
135
121
  ...action,
@@ -0,0 +1,50 @@
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;
@@ -0,0 +1,21 @@
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,7 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.importDefinition = void 0;
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");
4
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");
5
15
  const importDefinition = async (definition, integrationId) => {
6
16
  const result = await (0, graphql_1.gqlRequest)({
7
17
  document: (0, graphql_1.gql) `
@@ -44,3 +54,126 @@ const importDefinition = async (definition, integrationId) => {
44
54
  };
45
55
  };
46
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
+ forCodeNativeIntegration: 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;
@@ -0,0 +1,37 @@
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;
package/lib/yeoman.js CHANGED
@@ -13,6 +13,8 @@ const generatorTypes = [
13
13
  "dataSource",
14
14
  "connection",
15
15
  "formats",
16
+ "integration",
17
+ "flow",
16
18
  ];
17
19
  const runGenerator = async (generatorName, options) => {
18
20
  if (!generatorTypes.includes(generatorName)) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.10.0",
2
+ "version": "5.0.0-preview2",
3
3
  "commands": {
4
4
  "login": {
5
5
  "id": "login",
@@ -903,7 +903,7 @@
903
903
  },
904
904
  "integrations:import": {
905
905
  "id": "integrations:import",
906
- "description": "Import an Integration using a YAML definition file",
906
+ "description": "Import an Integration using a YAML definition file or a Code Native Integration",
907
907
  "strict": true,
908
908
  "pluginName": "@prismatic-io/prism",
909
909
  "pluginAlias": "@prismatic-io/prism",
@@ -914,8 +914,8 @@
914
914
  "name": "path",
915
915
  "type": "option",
916
916
  "char": "p",
917
- "description": "path to the YAML definition of the integration to import",
918
- "required": true,
917
+ "description": "If supplied, the path to the YAML definition of the integration to import. Not applicable for Code Native Integrations.",
918
+ "required": false,
919
919
  "multiple": false
920
920
  },
921
921
  "integrationId": {
@@ -929,9 +929,17 @@
929
929
  "icon-path": {
930
930
  "name": "icon-path",
931
931
  "type": "option",
932
- "description": "path to the PNG icon for the integration",
932
+ "description": "If supplied, the path to the PNG icon for the integration. Not applicable for Code Native Integrations.",
933
933
  "required": false,
934
934
  "multiple": false
935
+ },
936
+ "open": {
937
+ "name": "open",
938
+ "type": "boolean",
939
+ "char": "o",
940
+ "description": "If supplied, open the Designer for the imported integration",
941
+ "required": false,
942
+ "allowNo": false
935
943
  }
936
944
  },
937
945
  "args": {}
@@ -1083,6 +1091,23 @@
1083
1091
  }
1084
1092
  }
1085
1093
  },
1094
+ "integrations:open": {
1095
+ "id": "integrations:open",
1096
+ "description": "Open the Designer for the specified Integration",
1097
+ "strict": true,
1098
+ "pluginName": "@prismatic-io/prism",
1099
+ "pluginAlias": "@prismatic-io/prism",
1100
+ "pluginType": "core",
1101
+ "aliases": [],
1102
+ "flags": {},
1103
+ "args": {
1104
+ "integrationId": {
1105
+ "name": "integrationId",
1106
+ "description": "ID of the integration to open",
1107
+ "required": true
1108
+ }
1109
+ }
1110
+ },
1086
1111
  "integrations:publish": {
1087
1112
  "id": "integrations:publish",
1088
1113
  "description": "Publish a version of an Integration for use in Instances",
@@ -3292,6 +3317,45 @@
3292
3317
  }
3293
3318
  }
3294
3319
  },
3320
+ "integrations:init:flow": {
3321
+ "id": "integrations:init:flow",
3322
+ "description": "Initialize a new file for a Code Native Integration Flow",
3323
+ "strict": true,
3324
+ "pluginName": "@prismatic-io/prism",
3325
+ "pluginAlias": "@prismatic-io/prism",
3326
+ "pluginType": "core",
3327
+ "aliases": [],
3328
+ "flags": {},
3329
+ "args": {}
3330
+ },
3331
+ "integrations:init": {
3332
+ "id": "integrations:init",
3333
+ "description": "Initialize a new Code Native Integration",
3334
+ "strict": true,
3335
+ "pluginName": "@prismatic-io/prism",
3336
+ "pluginAlias": "@prismatic-io/prism",
3337
+ "pluginType": "core",
3338
+ "aliases": [],
3339
+ "flags": {},
3340
+ "args": {
3341
+ "name": {
3342
+ "name": "name",
3343
+ "description": "Name of the new integration to create (alphanumeric characters, hyphens, and underscores)",
3344
+ "required": true
3345
+ }
3346
+ }
3347
+ },
3348
+ "integrations:init:integration": {
3349
+ "id": "integrations:init:integration",
3350
+ "description": "Initialize a new Code Native Integration",
3351
+ "strict": true,
3352
+ "pluginName": "@prismatic-io/prism",
3353
+ "pluginAlias": "@prismatic-io/prism",
3354
+ "pluginType": "core",
3355
+ "aliases": [],
3356
+ "flags": {},
3357
+ "args": {}
3358
+ },
3295
3359
  "integrations:versions": {
3296
3360
  "id": "integrations:versions",
3297
3361
  "description": "List Integration versions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/prism",
3
- "version": "4.10.0",
3
+ "version": "5.0.0-preview2",
4
4
  "description": "Build, deploy, and support integrations in Prismatic from the comfort of your command line",
5
5
  "keywords": [
6
6
  "prismatic",
@@ -45,10 +45,10 @@
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": "2.3.1",
49
- "@prismatic-io/spectral": "7.9.0",
48
+ "@prismatic-io/generator-spectral": "3.0.0-preview2",
49
+ "@prismatic-io/spectral": "8.0.0-preview8",
50
50
  "archiver": "3.1.1",
51
- "axios": "1.6.2",
51
+ "axios": "0.21.4",
52
52
  "camelcase": "6.2.0",
53
53
  "chardet": "1.5.1",
54
54
  "dayjs": "1.11.0",
@@ -166,8 +166,5 @@
166
166
  "description": "Manage Organization Users"
167
167
  }
168
168
  }
169
- },
170
- "overrides": {
171
- "axios": "1.6.2"
172
169
  }
173
170
  }