@trayio/cdk-cli 2.11.0 → 2.12.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.
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.0 linux-x64 node-v18.19.0
22
+ @trayio/cdk-cli/2.12.0 linux-x64 node-v18.19.0
23
23
  $ tray-cdk --help [COMMAND]
24
24
  USAGE
25
25
  $ tray-cdk COMMAND
@@ -36,6 +36,7 @@ USAGE
36
36
  * [`tray-cdk build`](#tray-cdk-build)
37
37
  * [`tray-cdk deploy`](#tray-cdk-deploy)
38
38
  * [`tray-cdk help [COMMANDS]`](#tray-cdk-help-commands)
39
+ * [`tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`](#tray-cdk-import-openapi-spec-openapispec-connectorname)
39
40
  * [`tray-cdk init [CONNECTORNAME]`](#tray-cdk-init-connectorname)
40
41
  * [`tray-cdk test [OPERATIONNAME]`](#tray-cdk-test-operationname)
41
42
  * [`tray-cdk version`](#tray-cdk-version)
@@ -136,6 +137,22 @@ DESCRIPTION
136
137
 
137
138
  _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.9/src/commands/help.ts)_
138
139
 
140
+ ## `tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`
141
+
142
+ Create a connector from an OpenAPI specification: Command is still in BETA
143
+
144
+ ```
145
+ USAGE
146
+ $ tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]
147
+
148
+ ARGUMENTS
149
+ OPENAPISPEC Location of the OpenAPI specification file
150
+ CONNECTORNAME The name of the connector
151
+
152
+ DESCRIPTION
153
+ Create a connector from an OpenAPI specification: Command is still in BETA
154
+ ```
155
+
139
156
  ## `tray-cdk init [CONNECTORNAME]`
140
157
 
141
158
  Initialize a connector project
@@ -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/parser").Arg<string | undefined, Record<string, unknown>>;
6
+ connectorName: import("@oclif/core/lib/interfaces/parser").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/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;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.11.0",
2
+ "version": "2.12.0",
3
3
  "commands": {
4
4
  "add-operation": {
5
5
  "id": "add-operation",
@@ -49,6 +49,28 @@
49
49
  "flags": {},
50
50
  "args": {}
51
51
  },
52
+ "import-openapi-spec": {
53
+ "id": "import-openapi-spec",
54
+ "description": "Create a connector from an OpenAPI specification: Command is still in BETA",
55
+ "strict": true,
56
+ "pluginName": "@trayio/cdk-cli",
57
+ "pluginAlias": "@trayio/cdk-cli",
58
+ "pluginType": "core",
59
+ "aliases": [],
60
+ "flags": {},
61
+ "args": {
62
+ "openApiSpec": {
63
+ "name": "openApiSpec",
64
+ "description": "Location of the OpenAPI specification file",
65
+ "required": false
66
+ },
67
+ "connectorName": {
68
+ "name": "connectorName",
69
+ "description": "The name of the connector",
70
+ "required": false
71
+ }
72
+ }
73
+ },
52
74
  ".": {
53
75
  "id": ".",
54
76
  "pluginName": "@trayio/cdk-cli",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -19,11 +19,12 @@
19
19
  "@oclif/plugin-help": "5.2.9",
20
20
  "@oclif/plugin-version": "1.3.3",
21
21
  "@oclif/test": "2.3.17",
22
- "@trayio/axios": "2.11.0",
23
- "@trayio/cdk-build": "2.11.0",
24
- "@trayio/commons": "2.11.0",
25
- "@trayio/generator": "2.11.0",
26
- "@trayio/tray-client": "2.11.0",
22
+ "@trayio/axios": "2.12.0",
23
+ "@trayio/cdk-build": "2.12.0",
24
+ "@trayio/commons": "2.12.0",
25
+ "@trayio/generator": "2.12.0",
26
+ "@trayio/tray-client": "2.12.0",
27
+ "@trayio/tray-openapi": "2.12.0",
27
28
  "@types/inquirer": "8.2.6",
28
29
  "chalk": "4.1.2",
29
30
  "inquirer": "8.2.5"