@trayio/cdk-cli 2.11.1 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +44 -7
  2. package/dist/commands/add-operation.d.ts +10 -0
  3. package/dist/commands/add-operation.d.ts.map +1 -0
  4. package/dist/commands/build.d.ts.map +1 -0
  5. package/dist/commands/deploy.d.ts.map +1 -0
  6. package/dist/commands/deployment-status.d.ts +12 -0
  7. package/dist/commands/deployment-status.d.ts.map +1 -0
  8. package/dist/commands/deployment-status.js +78 -0
  9. package/dist/commands/deployment-status.test.d.ts +2 -0
  10. package/dist/commands/deployment-status.test.d.ts.map +1 -0
  11. package/dist/commands/deployment-status.test.js +82 -0
  12. package/dist/commands/import-openapi-spec.d.ts +10 -0
  13. package/dist/commands/import-openapi-spec.d.ts.map +1 -0
  14. package/dist/commands/import-openapi-spec.js +101 -0
  15. package/dist/commands/index.d.ts.map +1 -0
  16. package/dist/{init.d.ts → commands/init.d.ts} +1 -1
  17. package/dist/commands/init.d.ts.map +1 -0
  18. package/dist/{test.d.ts → commands/test.d.ts} +1 -1
  19. package/dist/commands/test.d.ts.map +1 -0
  20. package/dist/utils/colorizeString.d.ts +5 -0
  21. package/dist/utils/colorizeString.d.ts.map +1 -0
  22. package/dist/utils/colorizeString.js +35 -0
  23. package/oclif.manifest.json +178 -58
  24. package/package.json +13 -12
  25. package/dist/add-operation.d.ts +0 -10
  26. package/dist/add-operation.d.ts.map +0 -1
  27. package/dist/build.d.ts.map +0 -1
  28. package/dist/deploy.d.ts.map +0 -1
  29. package/dist/index.d.ts.map +0 -1
  30. package/dist/init.d.ts.map +0 -1
  31. package/dist/test.d.ts.map +0 -1
  32. /package/dist/{add-operation.js → commands/add-operation.js} +0 -0
  33. /package/dist/{build.d.ts → commands/build.d.ts} +0 -0
  34. /package/dist/{build.js → commands/build.js} +0 -0
  35. /package/dist/{composite-operation-template.zip → commands/composite-operation-template.zip} +0 -0
  36. /package/dist/{connector-template.zip → commands/connector-template.zip} +0 -0
  37. /package/dist/{deploy.d.ts → commands/deploy.d.ts} +0 -0
  38. /package/dist/{deploy.js → commands/deploy.js} +0 -0
  39. /package/dist/{http-operation-template.zip → commands/http-operation-template.zip} +0 -0
  40. /package/dist/{index.d.ts → commands/index.d.ts} +0 -0
  41. /package/dist/{index.js → commands/index.js} +0 -0
  42. /package/dist/{init.js → commands/init.js} +0 -0
  43. /package/dist/{test.js → commands/test.js} +0 -0
package/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install -g @trayio/cdk-cli
19
19
  $ tray-cdk COMMAND
20
20
  running command...
21
21
  $ tray-cdk (--version|-v)
22
- @trayio/cdk-cli/2.11.1 linux-x64 node-v18.19.0
22
+ @trayio/cdk-cli/2.13.0 linux-x64 node-v18.19.0
23
23
  $ tray-cdk --help [COMMAND]
24
24
  USAGE
25
25
  $ tray-cdk COMMAND
@@ -35,7 +35,9 @@ USAGE
35
35
  * [`tray-cdk autocomplete [SHELL]`](#tray-cdk-autocomplete-shell)
36
36
  * [`tray-cdk build`](#tray-cdk-build)
37
37
  * [`tray-cdk deploy`](#tray-cdk-deploy)
38
+ * [`tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID`](#tray-cdk-deployment-status-connectorname-connectorversion-uuid)
38
39
  * [`tray-cdk help [COMMANDS]`](#tray-cdk-help-commands)
40
+ * [`tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`](#tray-cdk-import-openapi-spec-openapispec-connectorname)
39
41
  * [`tray-cdk init [CONNECTORNAME]`](#tray-cdk-init-connectorname)
40
42
  * [`tray-cdk test [OPERATIONNAME]`](#tray-cdk-test-operationname)
41
43
  * [`tray-cdk version`](#tray-cdk-version)
@@ -65,20 +67,20 @@ DESCRIPTION
65
67
 
66
68
  ## `tray-cdk autocomplete [SHELL]`
67
69
 
68
- display autocomplete installation instructions
70
+ Display autocomplete installation instructions.
69
71
 
70
72
  ```
71
73
  USAGE
72
74
  $ tray-cdk autocomplete [SHELL] [-r]
73
75
 
74
76
  ARGUMENTS
75
- SHELL shell type
77
+ SHELL (zsh|bash|powershell) Shell type
76
78
 
77
79
  FLAGS
78
80
  -r, --refresh-cache Refresh cache (ignores displaying instructions)
79
81
 
80
82
  DESCRIPTION
81
- display autocomplete installation instructions
83
+ Display autocomplete installation instructions.
82
84
 
83
85
  EXAMPLES
84
86
  $ tray-cdk autocomplete
@@ -87,10 +89,12 @@ EXAMPLES
87
89
 
88
90
  $ tray-cdk autocomplete zsh
89
91
 
92
+ $ tray-cdk autocomplete powershell
93
+
90
94
  $ tray-cdk autocomplete --refresh-cache
91
95
  ```
92
96
 
93
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v2.1.9/src/commands/autocomplete/index.ts)_
97
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.5/src/commands/autocomplete/index.ts)_
94
98
 
95
99
  ## `tray-cdk build`
96
100
 
@@ -116,6 +120,23 @@ DESCRIPTION
116
120
  Deploys a connector project
117
121
  ```
118
122
 
123
+ ## `tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID`
124
+
125
+ Retrieves the status of a connector deployment
126
+
127
+ ```
128
+ USAGE
129
+ $ tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID
130
+
131
+ ARGUMENTS
132
+ CONNECTORNAME The name of the connector
133
+ CONNECTORVERSION The version of the connector
134
+ UUID The UUID of the deployment, this is included in the tray-cdk deploy output
135
+
136
+ DESCRIPTION
137
+ Retrieves the status of a connector deployment
138
+ ```
139
+
119
140
  ## `tray-cdk help [COMMANDS]`
120
141
 
121
142
  Display help for tray-cdk.
@@ -134,7 +155,23 @@ DESCRIPTION
134
155
  Display help for tray-cdk.
135
156
  ```
136
157
 
137
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.9/src/commands/help.ts)_
158
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.12/src/commands/help.ts)_
159
+
160
+ ## `tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`
161
+
162
+ Create a connector from an OpenAPI specification: Command is still in BETA
163
+
164
+ ```
165
+ USAGE
166
+ $ tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]
167
+
168
+ ARGUMENTS
169
+ OPENAPISPEC Location of the OpenAPI specification file
170
+ CONNECTORNAME The name of the connector
171
+
172
+ DESCRIPTION
173
+ Create a connector from an OpenAPI specification: Command is still in BETA
174
+ ```
138
175
 
139
176
  ## `tray-cdk init [CONNECTORNAME]`
140
177
 
@@ -190,5 +227,5 @@ FLAG DESCRIPTIONS
190
227
  Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
191
228
  ```
192
229
 
193
- _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v1.3.3/src/commands/version.ts)_
230
+ _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.0.11/src/commands/version.ts)_
194
231
  <!-- commandsstop -->
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AddOperation extends Command {
3
+ static description: string;
4
+ static args: {
5
+ operationName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
+ operationType: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=add-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-operation.d.ts","sourceRoot":"","sources":["../../src/commands/add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAC;AAqB5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAChD,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,IAAI;;;MAYT;IAEI,GAAG;CAyDT"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAClD,MAAM,CAAC,WAAW,SAAgC;IAElD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,gBAAgB,CAA0B;IAE5C,GAAG;CAMT"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAUtC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAAiC;IAEnD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CA2CT"}
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class GetDeploymentStatus extends Command {
3
+ static description: string;
4
+ static args: {
5
+ connectorName: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ connectorVersion: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ uuid: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
8
+ };
9
+ private connectorDeployment;
10
+ run(): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=deployment-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-status.d.ts","sourceRoot":"","sources":["../../src/commands/deployment-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,aAAa,CAAC;AAMhD,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;IACvD,MAAM,CAAC,WAAW,SAAoD;IAEtE,MAAM,CAAC,IAAI;;;;MAiBT;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CAuDT"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const core_1 = require("@oclif/core");
13
+ const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
14
+ const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
15
+ const ConnectorDeploymentApi_1 = require("@trayio/tray-api/connector/deployment/ConnectorDeploymentApi");
16
+ const colorizeString_1 = require("../utils/colorizeString");
17
+ class GetDeploymentStatus extends core_1.Command {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
21
+ baseUrl: process.env.TRAY_API_URL,
22
+ }, new AxiosHttpClient_1.AxiosHttpClient());
23
+ }
24
+ run() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { args } = yield this.parse(GetDeploymentStatus);
27
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
28
+ const input = {
29
+ connectorName: args.connectorName,
30
+ connectorVersion: args.connectorVersion,
31
+ id: args.uuid,
32
+ token: TRAY_API_TOKEN,
33
+ };
34
+ core_1.ux.action.start(`Checking the connector deployment status`);
35
+ const response = yield this.connectorDeployment.get(input);
36
+ core_1.ux.action.stop();
37
+ if (response.isSuccess) {
38
+ switch (response.value.deploymentStatus) {
39
+ case ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying:
40
+ this.log((0, colorizeString_1.info)(`Connector is currently being deployed, this could take a few minutes. Please check the connector status again later.`));
41
+ break;
42
+ case ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed:
43
+ this.log((0, colorizeString_1.success)(`Connector Deployed Successfully! 🎉 🎉 🎉`));
44
+ break;
45
+ case ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Failed:
46
+ this.log((0, colorizeString_1.error)(`Connector Deploy Failed, please try again or contact support`));
47
+ break;
48
+ default:
49
+ this.log((0, colorizeString_1.error)(`Connector Deploy Failed, please try again or contact support`));
50
+ break;
51
+ }
52
+ }
53
+ if (response.isFailure) {
54
+ this.log((0, colorizeString_1.error)(`Connector Deploy Failed, please try again or contact support`));
55
+ this.log(response.error.message);
56
+ }
57
+ });
58
+ }
59
+ }
60
+ GetDeploymentStatus.description = 'Retrieves the status of a connector deployment';
61
+ GetDeploymentStatus.args = {
62
+ connectorName: core_1.Args.string({
63
+ name: 'Connector Name',
64
+ required: true,
65
+ description: 'The name of the connector',
66
+ }),
67
+ connectorVersion: core_1.Args.string({
68
+ name: 'Connector Version',
69
+ required: true,
70
+ description: 'The version of the connector',
71
+ }),
72
+ uuid: core_1.Args.string({
73
+ name: 'Deployment UUID',
74
+ required: true,
75
+ description: 'The UUID of the deployment, this is included in the tray-cdk deploy output',
76
+ }),
77
+ };
78
+ exports.default = GetDeploymentStatus;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=deployment-status.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-status.test.d.ts","sourceRoot":"","sources":["../../src/commands/deployment-status.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const stdout_stderr_1 = require("stdout-stderr");
16
+ const ConnectorDeploymentApi_1 = require("@trayio/tray-api/connector/deployment/ConnectorDeploymentApi");
17
+ const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
18
+ const deployment_status_1 = __importDefault(require("./deployment-status"));
19
+ jest.mock('@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient', () => ({
20
+ ConnectorDeploymentHttpClient: jest.fn(),
21
+ }));
22
+ jest.mock('fs-extra', () => ({
23
+ readJsonSync: jest.fn().mockReturnValue({
24
+ name: 'connectorName',
25
+ version: '1.0',
26
+ }),
27
+ }));
28
+ describe('GetDeploymentStatus', () => {
29
+ let status;
30
+ let success = true;
31
+ let failure = false;
32
+ const connectorName = 'some-connector-name';
33
+ const connectorVersion = '1.0';
34
+ const uuid = 'test-uuid';
35
+ beforeEach(() => {
36
+ ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient.mockImplementation(() => ({
37
+ get: jest.fn().mockReturnValue(Object.assign(Object.assign(Object.assign({ isSuccess: success }, (success && {
38
+ value: {
39
+ deploymentStatus: status,
40
+ },
41
+ })), { isFailure: failure }), (failure && {
42
+ error: {
43
+ message: 'There was an error fetching deployment status',
44
+ },
45
+ }))),
46
+ }));
47
+ });
48
+ afterAll(() => {
49
+ jest.clearAllMocks();
50
+ });
51
+ it('should log success message when connector is deployed', () => __awaiter(void 0, void 0, void 0, function* () {
52
+ status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed;
53
+ stdout_stderr_1.stdout.start();
54
+ yield deployment_status_1.default.run([connectorName, connectorVersion, uuid]);
55
+ stdout_stderr_1.stdout.stop();
56
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deployed Successfully!'));
57
+ }));
58
+ it('should log failed message when connector failed to deploy', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Failed;
60
+ stdout_stderr_1.stdout.start();
61
+ yield deployment_status_1.default.run([connectorName, connectorVersion, uuid]);
62
+ stdout_stderr_1.stdout.stop();
63
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deploy Failed, please try again or contact support'));
64
+ }));
65
+ it('should log connector is still deploying message when deploying', () => __awaiter(void 0, void 0, void 0, function* () {
66
+ status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying;
67
+ stdout_stderr_1.stdout.start();
68
+ yield deployment_status_1.default.run([connectorName, connectorVersion, uuid]);
69
+ stdout_stderr_1.stdout.stop();
70
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector is currently being deployed, this could take a few minutes. Please check the connector status again later.'));
71
+ }));
72
+ it('should log error messages when the request fails', () => __awaiter(void 0, void 0, void 0, function* () {
73
+ success = false;
74
+ failure = true;
75
+ status = ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Failed;
76
+ stdout_stderr_1.stdout.start();
77
+ yield deployment_status_1.default.run([connectorName, connectorVersion, uuid]);
78
+ stdout_stderr_1.stdout.stop();
79
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector Deploy Failed, please try again or contact support'));
80
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('There was an error fetching deployment status'));
81
+ }));
82
+ });
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class ImportOpenApiSpec extends Command {
3
+ static description: string;
4
+ static args: {
5
+ openApiSpec: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
+ connectorName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=import-openapi-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-openapi-spec.d.ts","sourceRoot":"","sources":["../../src/commands/import-openapi-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAC;AAS5C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,OAAO;IACrD,MAAM,CAAC,WAAW,SAC4D;IAE9E,MAAM,CAAC,IAAI;;;MAWT;IAEI,GAAG;CAiET"}
@@ -0,0 +1,101 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const core_1 = require("@oclif/core");
39
+ const OpenApiSchemaImporter_1 = require("@trayio/tray-openapi/OpenApiSchemaImporter");
40
+ const inquirer_1 = __importDefault(require("inquirer"));
41
+ const chalk_1 = __importDefault(require("chalk"));
42
+ const NodeFsGenerator_1 = require("@trayio/generator/generator/NodeFsGenerator");
43
+ const NodeFsFileStorage_1 = require("@trayio/commons/file/NodeFsFileStorage");
44
+ const E = __importStar(require("fp-ts/Either"));
45
+ const stream_1 = require("stream");
46
+ class ImportOpenApiSpec extends core_1.Command {
47
+ run() {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const { args } = yield this.parse(ImportOpenApiSpec);
50
+ const promptRes = yield inquirer_1.default.prompt([
51
+ {
52
+ name: 'openApiSpec',
53
+ message: 'OpenAPI specification file path',
54
+ type: 'input',
55
+ when: !args.openApiSpec,
56
+ },
57
+ {
58
+ name: 'connectorName',
59
+ message: 'Connector name',
60
+ type: 'input',
61
+ when: !args.connectorName,
62
+ },
63
+ ]);
64
+ const generator = new NodeFsGenerator_1.NodeFsGenerator();
65
+ const fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage(process.cwd());
66
+ const openApiSchemaImporter = new OpenApiSchemaImporter_1.OpenApiSchemaImporter(generator, fileStorage);
67
+ const openApiSpec = promptRes.openApiSpec || args.openApiSpec;
68
+ const connectorName = promptRes.connectorName || args.connectorName;
69
+ const result = yield openApiSchemaImporter.buildConnector(openApiSpec, connectorName)();
70
+ if (E.isLeft(result)) {
71
+ this.log(chalk_1.default.red(`Error occurred while importing connector: ${result.left.message}`));
72
+ }
73
+ else {
74
+ this.log(chalk_1.default.bold(chalk_1.default.green(`Success! Added connector: ${connectorName}`)));
75
+ this.log(chalk_1.default.bold.green(`Generated ${result.right.successes.length} Connector Operations`));
76
+ if (result.right.errors.length) {
77
+ this.log(chalk_1.default.bold.red(`Failed to generate ${result.right.errors.length} Connector Operations, errors can be found in the errors.json file`));
78
+ yield fileStorage.write({
79
+ key: 'errors.json',
80
+ content: stream_1.Readable.from(JSON.stringify(result.right.errors)),
81
+ metadata: { name: 'errors.json', size: 0 },
82
+ })();
83
+ }
84
+ }
85
+ });
86
+ }
87
+ }
88
+ ImportOpenApiSpec.description = 'Create a connector from an OpenAPI specification: Command is still in BETA';
89
+ ImportOpenApiSpec.args = {
90
+ openApiSpec: core_1.Args.string({
91
+ name: 'OpenAPI specification file path',
92
+ required: false,
93
+ description: 'Location of the OpenAPI specification file',
94
+ }),
95
+ connectorName: core_1.Args.string({
96
+ name: 'Connector name',
97
+ required: false,
98
+ description: 'The name of the connector',
99
+ }),
100
+ };
101
+ exports.default = ImportOpenApiSpec;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
2
2
  export default class Init extends Command {
3
3
  static description: string;
4
4
  static args: {
5
- connectorName: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
5
+ connectorName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
6
  };
7
7
  static flags: {
8
8
  install: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AAUnD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAAoC;IAEtD,MAAM,CAAC,IAAI;;MAMT;IAEF,MAAM,CAAC,KAAK;;MAKV;IAEI,GAAG;CAiDT"}
@@ -2,7 +2,7 @@ import { Command } from '@oclif/core';
2
2
  export default class Test extends Command {
3
3
  static description: string;
4
4
  static args: {
5
- operationName: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
5
+ operationName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
6
  };
7
7
  static flags: {
8
8
  verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AAMnD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAAsD;IAExE,MAAM,CAAC,IAAI;;MAMT;IAEF,MAAM,CAAC,KAAK;;MAMV;IAEI,GAAG;CAwBT"}
@@ -0,0 +1,5 @@
1
+ export declare const success: (message: string) => string;
2
+ export declare const error: (message: string) => string;
3
+ export declare const warning: (message: string) => string;
4
+ export declare const info: (message: string) => string;
5
+ //# sourceMappingURL=colorizeString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorizeString.d.ts","sourceRoot":"","sources":["../../src/utils/colorizeString.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,YAAa,MAAM,WAAqC,CAAC;AAE7E,eAAO,MAAM,KAAK,YAAa,MAAM,WAAmC,CAAC;AAEzE,eAAO,MAAM,OAAO,YAAa,MAAM,WAAsC,CAAC;AAE9E,eAAO,MAAM,IAAI,YAAa,MAAM,WAAoC,CAAC"}
@@ -0,0 +1,35 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.info = exports.warning = exports.error = exports.success = void 0;
27
+ const chalk = __importStar(require("chalk"));
28
+ const success = (message) => chalk.bold(chalk.green(message));
29
+ exports.success = success;
30
+ const error = (message) => chalk.bold(chalk.red(message));
31
+ exports.error = error;
32
+ const warning = (message) => chalk.bold(chalk.yellow(message));
33
+ exports.warning = warning;
34
+ const info = (message) => chalk.bold(chalk.blue(message));
35
+ exports.info = info;
@@ -1,112 +1,232 @@
1
1
  {
2
- "version": "2.11.1",
3
2
  "commands": {
4
3
  "add-operation": {
5
- "id": "add-operation",
6
- "description": "Add an operation to connector project",
7
- "strict": true,
8
- "pluginName": "@trayio/cdk-cli",
9
- "pluginAlias": "@trayio/cdk-cli",
10
- "pluginType": "core",
11
4
  "aliases": [],
12
- "flags": {},
13
5
  "args": {
14
6
  "operationName": {
15
- "name": "operationName",
16
7
  "description": "Operation name",
8
+ "name": "operationName",
17
9
  "required": false
18
10
  },
19
11
  "operationType": {
20
- "name": "operationType",
21
12
  "description": "Operation type",
22
- "required": false,
13
+ "name": "operationType",
23
14
  "options": [
24
15
  "http",
25
16
  "composite"
26
- ]
17
+ ],
18
+ "required": false
27
19
  }
28
- }
20
+ },
21
+ "description": "Add an operation to connector project",
22
+ "flags": {},
23
+ "hasDynamicHelp": false,
24
+ "hiddenAliases": [],
25
+ "id": "add-operation",
26
+ "pluginAlias": "@trayio/cdk-cli",
27
+ "pluginName": "@trayio/cdk-cli",
28
+ "pluginType": "core",
29
+ "strict": true,
30
+ "enableJsonFlag": false,
31
+ "isESM": false,
32
+ "relativePath": [
33
+ "dist",
34
+ "commands",
35
+ "add-operation.js"
36
+ ]
29
37
  },
30
38
  "build": {
31
- "id": "build",
39
+ "aliases": [],
40
+ "args": {},
32
41
  "description": "Builds a connector project",
33
- "strict": true,
34
- "pluginName": "@trayio/cdk-cli",
42
+ "flags": {},
43
+ "hasDynamicHelp": false,
44
+ "hiddenAliases": [],
45
+ "id": "build",
35
46
  "pluginAlias": "@trayio/cdk-cli",
47
+ "pluginName": "@trayio/cdk-cli",
36
48
  "pluginType": "core",
37
- "aliases": [],
38
- "flags": {},
39
- "args": {}
49
+ "strict": true,
50
+ "enableJsonFlag": false,
51
+ "isESM": false,
52
+ "relativePath": [
53
+ "dist",
54
+ "commands",
55
+ "build.js"
56
+ ]
40
57
  },
41
58
  "deploy": {
42
- "id": "deploy",
59
+ "aliases": [],
60
+ "args": {},
43
61
  "description": "Deploys a connector project",
44
- "strict": true,
62
+ "flags": {},
63
+ "hasDynamicHelp": false,
64
+ "hiddenAliases": [],
65
+ "id": "deploy",
66
+ "pluginAlias": "@trayio/cdk-cli",
45
67
  "pluginName": "@trayio/cdk-cli",
68
+ "pluginType": "core",
69
+ "strict": true,
70
+ "enableJsonFlag": false,
71
+ "isESM": false,
72
+ "relativePath": [
73
+ "dist",
74
+ "commands",
75
+ "deploy.js"
76
+ ]
77
+ },
78
+ "deployment-status": {
79
+ "aliases": [],
80
+ "args": {
81
+ "connectorName": {
82
+ "description": "The name of the connector",
83
+ "name": "connectorName",
84
+ "required": true
85
+ },
86
+ "connectorVersion": {
87
+ "description": "The version of the connector",
88
+ "name": "connectorVersion",
89
+ "required": true
90
+ },
91
+ "uuid": {
92
+ "description": "The UUID of the deployment, this is included in the tray-cdk deploy output",
93
+ "name": "uuid",
94
+ "required": true
95
+ }
96
+ },
97
+ "description": "Retrieves the status of a connector deployment",
98
+ "flags": {},
99
+ "hasDynamicHelp": false,
100
+ "hiddenAliases": [],
101
+ "id": "deployment-status",
46
102
  "pluginAlias": "@trayio/cdk-cli",
103
+ "pluginName": "@trayio/cdk-cli",
47
104
  "pluginType": "core",
105
+ "strict": true,
106
+ "enableJsonFlag": false,
107
+ "isESM": false,
108
+ "relativePath": [
109
+ "dist",
110
+ "commands",
111
+ "deployment-status.js"
112
+ ]
113
+ },
114
+ "import-openapi-spec": {
48
115
  "aliases": [],
116
+ "args": {
117
+ "openApiSpec": {
118
+ "description": "Location of the OpenAPI specification file",
119
+ "name": "openApiSpec",
120
+ "required": false
121
+ },
122
+ "connectorName": {
123
+ "description": "The name of the connector",
124
+ "name": "connectorName",
125
+ "required": false
126
+ }
127
+ },
128
+ "description": "Create a connector from an OpenAPI specification: Command is still in BETA",
49
129
  "flags": {},
50
- "args": {}
130
+ "hasDynamicHelp": false,
131
+ "hiddenAliases": [],
132
+ "id": "import-openapi-spec",
133
+ "pluginAlias": "@trayio/cdk-cli",
134
+ "pluginName": "@trayio/cdk-cli",
135
+ "pluginType": "core",
136
+ "strict": true,
137
+ "enableJsonFlag": false,
138
+ "isESM": false,
139
+ "relativePath": [
140
+ "dist",
141
+ "commands",
142
+ "import-openapi-spec.js"
143
+ ]
51
144
  },
52
145
  ".": {
146
+ "aliases": [],
147
+ "args": {},
148
+ "flags": {},
149
+ "hasDynamicHelp": false,
150
+ "hiddenAliases": [],
53
151
  "id": ".",
54
- "pluginName": "@trayio/cdk-cli",
55
152
  "pluginAlias": "@trayio/cdk-cli",
153
+ "pluginName": "@trayio/cdk-cli",
56
154
  "pluginType": "core",
57
- "aliases": [],
58
- "flags": {},
59
- "args": {}
155
+ "isESM": false,
156
+ "relativePath": [
157
+ "dist",
158
+ "commands",
159
+ "index.js"
160
+ ]
60
161
  },
61
162
  "init": {
62
- "id": "init",
63
- "description": "Initialize a connector project",
64
- "strict": true,
65
- "pluginName": "@trayio/cdk-cli",
66
- "pluginAlias": "@trayio/cdk-cli",
67
- "pluginType": "core",
68
163
  "aliases": [],
164
+ "args": {
165
+ "connectorName": {
166
+ "description": "Connector directory name to generate template files",
167
+ "name": "connectorName",
168
+ "required": false
169
+ }
170
+ },
171
+ "description": "Initialize a connector project",
69
172
  "flags": {
70
173
  "install": {
71
- "name": "install",
72
- "type": "boolean",
73
174
  "char": "i",
74
175
  "description": "Runs `npm install` after successful generation",
75
- "allowNo": false
176
+ "name": "install",
177
+ "allowNo": false,
178
+ "type": "boolean"
76
179
  }
77
180
  },
181
+ "hasDynamicHelp": false,
182
+ "hiddenAliases": [],
183
+ "id": "init",
184
+ "pluginAlias": "@trayio/cdk-cli",
185
+ "pluginName": "@trayio/cdk-cli",
186
+ "pluginType": "core",
187
+ "strict": true,
188
+ "enableJsonFlag": false,
189
+ "isESM": false,
190
+ "relativePath": [
191
+ "dist",
192
+ "commands",
193
+ "init.js"
194
+ ]
195
+ },
196
+ "test": {
197
+ "aliases": [],
78
198
  "args": {
79
- "connectorName": {
80
- "name": "connectorName",
81
- "description": "Connector directory name to generate template files",
199
+ "operationName": {
200
+ "description": "Operation name to run the test against",
201
+ "name": "operationName",
82
202
  "required": false
83
203
  }
84
- }
85
- },
86
- "test": {
87
- "id": "test",
204
+ },
88
205
  "description": "Build and test connector project or an operation",
89
- "strict": true,
90
- "pluginName": "@trayio/cdk-cli",
91
- "pluginAlias": "@trayio/cdk-cli",
92
- "pluginType": "core",
93
- "aliases": [],
94
206
  "flags": {
95
207
  "verbose": {
96
- "name": "verbose",
97
- "type": "boolean",
98
208
  "char": "v",
99
209
  "description": "Logs the input and output of an operation, requires operation name argument to be specified",
100
- "allowNo": false
210
+ "name": "verbose",
211
+ "allowNo": false,
212
+ "type": "boolean"
101
213
  }
102
214
  },
103
- "args": {
104
- "operationName": {
105
- "name": "operationName",
106
- "description": "Operation name to run the test against",
107
- "required": false
108
- }
109
- }
215
+ "hasDynamicHelp": false,
216
+ "hiddenAliases": [],
217
+ "id": "test",
218
+ "pluginAlias": "@trayio/cdk-cli",
219
+ "pluginName": "@trayio/cdk-cli",
220
+ "pluginType": "core",
221
+ "strict": true,
222
+ "enableJsonFlag": false,
223
+ "isESM": false,
224
+ "relativePath": [
225
+ "dist",
226
+ "commands",
227
+ "test.js"
228
+ ]
110
229
  }
111
- }
230
+ },
231
+ "version": "2.13.0"
112
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "2.11.1",
3
+ "version": "2.13.0",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -14,16 +14,17 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@oclif/core": "2.8.4",
18
- "@oclif/plugin-autocomplete": "2.1.9",
19
- "@oclif/plugin-help": "5.2.9",
20
- "@oclif/plugin-version": "1.3.3",
21
- "@oclif/test": "2.3.17",
22
- "@trayio/axios": "2.11.1",
23
- "@trayio/cdk-build": "2.11.1",
24
- "@trayio/commons": "2.11.1",
25
- "@trayio/generator": "2.11.1",
26
- "@trayio/tray-client": "2.11.1",
17
+ "@oclif/core": "3.18.1",
18
+ "@oclif/plugin-autocomplete": "3.0.5",
19
+ "@oclif/plugin-help": "6.0.12",
20
+ "@oclif/plugin-version": "2.0.11",
21
+ "@oclif/test": "3.1.12",
22
+ "@trayio/axios": "2.13.0",
23
+ "@trayio/cdk-build": "2.13.0",
24
+ "@trayio/commons": "2.13.0",
25
+ "@trayio/generator": "2.13.0",
26
+ "@trayio/tray-client": "2.13.0",
27
+ "@trayio/tray-openapi": "2.13.0",
27
28
  "@types/inquirer": "8.2.6",
28
29
  "chalk": "4.1.2",
29
30
  "inquirer": "8.2.5"
@@ -46,7 +47,7 @@
46
47
  "tray-cdk": "./bin/run"
47
48
  },
48
49
  "oclif": {
49
- "commands": "./dist",
50
+ "commands": "./dist/commands",
50
51
  "bin": "tray-cdk",
51
52
  "topicSeparator": " ",
52
53
  "plugins": [
@@ -1,10 +0,0 @@
1
- import { Command } from '@oclif/core';
2
- export default class AddOperation extends Command {
3
- static description: string;
4
- static args: {
5
- operationName: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
6
- operationType: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
7
- };
8
- run(): Promise<void>;
9
- }
10
- //# sourceMappingURL=add-operation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-operation.d.ts","sourceRoot":"","sources":["../src/add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAC;AAqB5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAChD,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,IAAI;;;MAYT;IAEI,GAAG;CAyDT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAClD,MAAM,CAAC,WAAW,SAAgC;IAElD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,gBAAgB,CAA0B;IAE5C,GAAG;CAMT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAUtC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAAiC;IAEnD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CA2CT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AAUnD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAAoC;IAEtD,MAAM,CAAC,IAAI;;MAMT;IAEF,MAAM,CAAC,KAAK;;MAKV;IAEI,GAAG;CAiDT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,aAAa,CAAC;AAMnD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACxC,MAAM,CAAC,WAAW,SAAsD;IAExE,MAAM,CAAC,IAAI;;MAMT;IAEF,MAAM,CAAC,KAAK;;MAMV;IAEI,GAAG;CAwBT"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes