@prismatic-io/prism 3.2.2 → 4.1.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/bin/run +9 -8
- package/lib/auth.js +184 -202
- package/lib/commands/alerts/events/list.js +27 -57
- package/lib/commands/alerts/groups/create.js +18 -49
- package/lib/commands/alerts/groups/delete.js +10 -41
- package/lib/commands/alerts/groups/list.js +15 -47
- package/lib/commands/alerts/monitors/clear.js +10 -41
- package/lib/commands/alerts/monitors/create.js +27 -58
- package/lib/commands/alerts/monitors/delete.js +10 -41
- package/lib/commands/alerts/monitors/list.js +16 -48
- package/lib/commands/alerts/triggers/list.js +15 -47
- package/lib/commands/alerts/webhooks/create.js +18 -49
- package/lib/commands/alerts/webhooks/delete.js +10 -41
- package/lib/commands/alerts/webhooks/list.js +25 -57
- package/lib/commands/authorization-methods/list.js +20 -51
- package/lib/commands/components/actions/list.js +29 -61
- package/lib/commands/components/delete.js +10 -41
- package/lib/commands/components/dev/run.js +75 -0
- package/lib/commands/components/dev/test.js +218 -0
- package/lib/commands/components/init/action.js +12 -0
- package/lib/commands/components/init/component.js +12 -0
- package/lib/commands/components/init/connection.js +12 -0
- package/lib/commands/components/init/index.js +203 -0
- package/lib/commands/components/init/trigger.js +12 -0
- package/lib/commands/components/list.js +31 -60
- package/lib/commands/components/publish.js +29 -279
- package/lib/commands/components/triggers/list.js +29 -61
- package/lib/commands/customers/create.js +14 -45
- package/lib/commands/customers/credentials/create.js +19 -50
- package/lib/commands/customers/credentials/delete.js +10 -41
- package/lib/commands/customers/credentials/list.js +30 -59
- package/lib/commands/customers/credentials/update.js +16 -47
- package/lib/commands/customers/delete.js +10 -41
- package/lib/commands/customers/list.js +16 -48
- package/lib/commands/customers/update.js +15 -46
- package/lib/commands/customers/users/create.js +18 -49
- package/lib/commands/customers/users/delete.js +10 -41
- package/lib/commands/customers/users/list.js +21 -51
- package/lib/commands/customers/users/roles.js +18 -48
- package/lib/commands/customers/users/update.js +19 -50
- package/lib/commands/executions/step-result/get.js +36 -66
- package/lib/commands/instances/config-vars/list.js +32 -62
- package/lib/commands/instances/create.js +20 -51
- package/lib/commands/instances/delete.js +10 -41
- package/lib/commands/instances/deploy.js +20 -44
- package/lib/commands/instances/disable.js +11 -42
- package/lib/commands/instances/enable.js +11 -42
- package/lib/commands/instances/flow-configs/list.js +25 -55
- package/lib/commands/instances/flow-configs/test.js +62 -97
- package/lib/commands/instances/list.js +31 -59
- package/lib/commands/instances/update.js +15 -46
- package/lib/commands/integrations/available.js +13 -44
- package/lib/commands/integrations/create.js +14 -45
- package/lib/commands/integrations/delete.js +10 -41
- package/lib/commands/integrations/export.js +16 -59
- package/lib/commands/integrations/flows/list.js +22 -52
- package/lib/commands/integrations/flows/test.js +62 -96
- package/lib/commands/integrations/fork.js +15 -46
- package/lib/commands/integrations/import.js +12 -63
- package/lib/commands/integrations/list.js +25 -54
- package/lib/commands/integrations/publish.js +13 -44
- package/lib/commands/integrations/update.js +18 -49
- package/lib/commands/integrations/versions/index.js +26 -58
- package/lib/commands/login.js +16 -32
- package/lib/commands/logout.js +10 -22
- package/lib/commands/logs/severities/list.js +15 -47
- package/lib/commands/me/index.js +13 -60
- package/lib/commands/me/token/revoke.js +12 -0
- package/lib/commands/me/token.js +10 -22
- package/lib/commands/organization/credentials/create.js +17 -48
- package/lib/commands/organization/credentials/delete.js +10 -41
- package/lib/commands/organization/credentials/list.js +22 -54
- package/lib/commands/organization/credentials/update.js +16 -47
- package/lib/commands/organization/update.js +12 -43
- package/lib/commands/organization/updateAvatarUrl.js +14 -45
- package/lib/commands/organization/users/create.js +16 -47
- package/lib/commands/organization/users/delete.js +10 -41
- package/lib/commands/organization/users/list.js +16 -48
- package/lib/commands/organization/users/roles.js +18 -48
- package/lib/commands/organization/users/update.js +19 -50
- package/lib/config.js +24 -30
- package/lib/errors.js +48 -27
- package/lib/fields.js +6 -4
- package/lib/fs.js +6 -14
- package/lib/generate/action.js +36 -41
- package/lib/generate/client.js +11 -16
- package/lib/generate/connection.js +4 -13
- package/lib/generate/index.js +29 -19
- package/lib/generate/input.js +28 -43
- package/lib/generate/parse.js +38 -44
- package/lib/generate/sourceFile.js +11 -7
- package/lib/generate/util.js +9 -7
- package/lib/graphql.js +37 -65
- package/lib/index.js +3 -3
- package/lib/utils/component/publish.js +219 -0
- package/lib/utils/component/query.js +23 -0
- package/lib/utils/date.js +14 -0
- package/lib/utils/execution/logs.js +86 -0
- package/lib/utils/integration/definition.js +101 -0
- package/lib/utils/integration/export.js +36 -0
- package/lib/utils/integration/import.js +46 -0
- package/lib/utils/integration/invoke.js +64 -0
- package/lib/utils/integration/query.js +59 -0
- package/lib/utils/serialize.js +8 -0
- package/lib/utils/user/query.js +24 -0
- package/lib/yeoman.js +23 -0
- package/oclif.manifest.json +1 -1
- package/package.json +48 -54
- package/templates/component/openapi/client.ts +11 -9
- package/templates/component/openapi/request.ts +6 -4
- package/lib/auth.js.map +0 -1
- package/lib/commands/alerts/events/list.js.map +0 -1
- package/lib/commands/alerts/groups/create.js.map +0 -1
- package/lib/commands/alerts/groups/delete.js.map +0 -1
- package/lib/commands/alerts/groups/list.js.map +0 -1
- package/lib/commands/alerts/monitors/clear.js.map +0 -1
- package/lib/commands/alerts/monitors/create.js.map +0 -1
- package/lib/commands/alerts/monitors/delete.js.map +0 -1
- package/lib/commands/alerts/monitors/list.js.map +0 -1
- package/lib/commands/alerts/triggers/list.js.map +0 -1
- package/lib/commands/alerts/webhooks/create.js.map +0 -1
- package/lib/commands/alerts/webhooks/delete.js.map +0 -1
- package/lib/commands/alerts/webhooks/list.js.map +0 -1
- package/lib/commands/authorization-methods/list.js.map +0 -1
- package/lib/commands/components/actions/list.js.map +0 -1
- package/lib/commands/components/delete.js.map +0 -1
- package/lib/commands/components/init.js +0 -224
- package/lib/commands/components/init.js.map +0 -1
- package/lib/commands/components/list.js.map +0 -1
- package/lib/commands/components/publish.js.map +0 -1
- package/lib/commands/components/triggers/list.js.map +0 -1
- package/lib/commands/customers/create.js.map +0 -1
- package/lib/commands/customers/credentials/create.js.map +0 -1
- package/lib/commands/customers/credentials/delete.js.map +0 -1
- package/lib/commands/customers/credentials/list.js.map +0 -1
- package/lib/commands/customers/credentials/update.js.map +0 -1
- package/lib/commands/customers/delete.js.map +0 -1
- package/lib/commands/customers/list.js.map +0 -1
- package/lib/commands/customers/update.js.map +0 -1
- package/lib/commands/customers/users/create.js.map +0 -1
- package/lib/commands/customers/users/delete.js.map +0 -1
- package/lib/commands/customers/users/list.js.map +0 -1
- package/lib/commands/customers/users/roles.js.map +0 -1
- package/lib/commands/customers/users/update.js.map +0 -1
- package/lib/commands/executions/step-result/get.js.map +0 -1
- package/lib/commands/instances/config-vars/list.js.map +0 -1
- package/lib/commands/instances/create.js.map +0 -1
- package/lib/commands/instances/delete.js.map +0 -1
- package/lib/commands/instances/deploy.js.map +0 -1
- package/lib/commands/instances/disable.js.map +0 -1
- package/lib/commands/instances/enable.js.map +0 -1
- package/lib/commands/instances/flow-configs/list.js.map +0 -1
- package/lib/commands/instances/flow-configs/test.js.map +0 -1
- package/lib/commands/instances/list.js.map +0 -1
- package/lib/commands/instances/update.js.map +0 -1
- package/lib/commands/integrations/available.js.map +0 -1
- package/lib/commands/integrations/create.js.map +0 -1
- package/lib/commands/integrations/delete.js.map +0 -1
- package/lib/commands/integrations/export.js.map +0 -1
- package/lib/commands/integrations/flows/list.js.map +0 -1
- package/lib/commands/integrations/flows/test.js.map +0 -1
- package/lib/commands/integrations/fork.js.map +0 -1
- package/lib/commands/integrations/import.js.map +0 -1
- package/lib/commands/integrations/list.js.map +0 -1
- package/lib/commands/integrations/publish.js.map +0 -1
- package/lib/commands/integrations/update.js.map +0 -1
- package/lib/commands/integrations/versions/index.js.map +0 -1
- package/lib/commands/login.js.map +0 -1
- package/lib/commands/logout.js.map +0 -1
- package/lib/commands/logs/severities/list.js.map +0 -1
- package/lib/commands/me/index.js.map +0 -1
- package/lib/commands/me/token.js.map +0 -1
- package/lib/commands/organization/credentials/create.js.map +0 -1
- package/lib/commands/organization/credentials/delete.js.map +0 -1
- package/lib/commands/organization/credentials/list.js.map +0 -1
- package/lib/commands/organization/credentials/update.js.map +0 -1
- package/lib/commands/organization/update.js.map +0 -1
- package/lib/commands/organization/updateAvatarUrl.js.map +0 -1
- package/lib/commands/organization/users/create.js.map +0 -1
- package/lib/commands/organization/users/delete.js.map +0 -1
- package/lib/commands/organization/users/list.js.map +0 -1
- package/lib/commands/organization/users/roles.js.map +0 -1
- package/lib/commands/organization/users/update.js.map +0 -1
- package/lib/config.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/fields.js.map +0 -1
- package/lib/fs.js.map +0 -1
- package/lib/generate/action.js.map +0 -1
- package/lib/generate/client.js.map +0 -1
- package/lib/generate/connection.js.map +0 -1
- package/lib/generate/index.js.map +0 -1
- package/lib/generate/input.js.map +0 -1
- package/lib/generate/parse.js.map +0 -1
- package/lib/generate/sourceFile.js.map +0 -1
- package/lib/generate/util.js.map +0 -1
- package/lib/graphql.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/templates/component/jest.config.js +0 -4
- package/templates/component/package.json +0 -24
- package/templates/component/src/actions.ts +0 -33
- package/templates/component/src/client.ts +0 -7
- package/templates/component/src/connections.ts +0 -25
- package/templates/component/src/index.test.ts +0 -32
- package/templates/component/src/index.ts +0 -17
- package/templates/component/src/triggers.ts +0 -18
- package/templates/component/tsconfig.json +0 -19
- package/templates/component/webpack.config.js +0 -44
package/lib/generate/client.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,25 +18,16 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
26
|
exports.generateClient = void 0;
|
|
32
27
|
const ts_morph_1 = require("ts-morph");
|
|
33
28
|
const fs_1 = require("fs");
|
|
34
29
|
const path = __importStar(require("path"));
|
|
35
|
-
|
|
30
|
+
const generateClient = async (project) => {
|
|
36
31
|
const { clientFile } = project;
|
|
37
32
|
if (clientFile === undefined) {
|
|
38
33
|
return;
|
|
@@ -86,13 +81,13 @@ exports.generateClient = (project) => __awaiter(void 0, void 0, void 0, function
|
|
|
86
81
|
declarations: [
|
|
87
82
|
{
|
|
88
83
|
name: "initializeClient",
|
|
89
|
-
initializer: String(
|
|
84
|
+
initializer: String(await fs_1.promises.readFile(path.resolve(__dirname, "..", "..", "templates", "component", "openapi", "client.ts"))),
|
|
90
85
|
},
|
|
91
86
|
],
|
|
92
87
|
isExported: true,
|
|
93
88
|
},
|
|
94
89
|
]);
|
|
95
90
|
clientFile.formatText();
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
91
|
+
await clientFile.save();
|
|
92
|
+
};
|
|
93
|
+
exports.generateClient = generateClient;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.generateConnections = void 0;
|
|
13
4
|
const ts_morph_1 = require("ts-morph");
|
|
14
|
-
|
|
5
|
+
const generateConnections = async (project) => {
|
|
15
6
|
const { connectionsFile } = project;
|
|
16
7
|
if (connectionsFile === undefined) {
|
|
17
8
|
return;
|
|
@@ -81,6 +72,6 @@ exports.generateConnections = (project) => __awaiter(void 0, void 0, void 0, fun
|
|
|
81
72
|
});
|
|
82
73
|
connectionsFile.organizeImports();
|
|
83
74
|
connectionsFile.formatText();
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
75
|
+
await connectionsFile.save();
|
|
76
|
+
};
|
|
77
|
+
exports.generateConnections = generateConnections;
|
package/lib/generate/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,37 +18,43 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
27
|
};
|
|
30
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.generate = void 0;
|
|
29
|
+
exports.updatePackageJson = exports.generate = void 0;
|
|
32
30
|
const path = __importStar(require("path"));
|
|
33
31
|
const sourceFile_1 = require("./sourceFile");
|
|
34
32
|
const action_1 = require("./action");
|
|
35
33
|
const client_1 = require("./client");
|
|
36
34
|
const connection_1 = require("./connection");
|
|
37
|
-
|
|
35
|
+
const prettier_1 = __importDefault(require("prettier"));
|
|
36
|
+
const fs_extra_1 = require("fs-extra");
|
|
37
|
+
const generate = async ({ projectRoot, projectTemplateName, projectTemplatePath, projectType, includeClient, addRetry, }) => {
|
|
38
38
|
var _a;
|
|
39
|
-
const project = sourceFile_1.initializeProject(projectRoot, projectTemplateName, projectTemplatePath, projectType, includeClient, addRetry);
|
|
39
|
+
const project = (0, sourceFile_1.initializeProject)(projectRoot, projectTemplateName, projectTemplatePath, projectType, includeClient, addRetry);
|
|
40
40
|
const { componentProject } = project;
|
|
41
41
|
if (projectType === "openApi" && includeClient) {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
await (0, client_1.generateClient)(project);
|
|
43
|
+
await (0, connection_1.generateConnections)(project);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
await (0, action_1.generateActions)(project, includeClient, projectType === "openApi" && addRetry);
|
|
46
46
|
(_a = componentProject
|
|
47
47
|
.getSourceFile(path.join(projectRoot, "src", "index.test.ts"))) === null || _a === void 0 ? void 0 : _a.delete();
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
48
|
+
await componentProject.save();
|
|
49
|
+
};
|
|
50
|
+
exports.generate = generate;
|
|
51
|
+
const updatePackageJson = async ({ path, dependencies = {}, devDependencies = {}, }) => {
|
|
52
|
+
const contents = await (0, fs_extra_1.readJson)(path, { encoding: "utf-8" });
|
|
53
|
+
Object.assign(contents.dependencies, dependencies);
|
|
54
|
+
Object.assign(contents.devDependencies, devDependencies);
|
|
55
|
+
const formatted = prettier_1.default.format(JSON.stringify(contents, null, 2), {
|
|
56
|
+
parser: "json",
|
|
57
|
+
});
|
|
58
|
+
await (0, fs_extra_1.writeFile)(path, formatted);
|
|
59
|
+
};
|
|
60
|
+
exports.updatePackageJson = updatePackageJson;
|
package/lib/generate/input.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,39 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.writeInputs = exports.getActionMethodInputProperties = void 0;
|
|
16
7
|
const ts_morph_1 = require("ts-morph");
|
|
17
8
|
const camelcase_1 = __importDefault(require("camelcase"));
|
|
18
|
-
|
|
9
|
+
const getActionMethodInputProperties = (parameter, parameterTypeDefinition) => {
|
|
19
10
|
const paramName = parameter.getName();
|
|
20
11
|
const propertyStructures = [];
|
|
21
12
|
if (parameterTypeDefinition) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
propertyStructures.push(propertyStructure);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
throw new Error(error);
|
|
50
|
-
}
|
|
13
|
+
const paramDefinition = parameterTypeDefinition.getInterfaceOrThrow((0, camelcase_1.default)(!paramName.includes("Param") ? paramName : paramName.split("Param")[0], { pascalCase: true }));
|
|
14
|
+
const paramProperties = paramDefinition.getProperties();
|
|
15
|
+
paramProperties.forEach((property) => {
|
|
16
|
+
// If its a single numeric the import of the input field will fail
|
|
17
|
+
// Assume single character inputs just suck
|
|
18
|
+
// and set it as a modified field
|
|
19
|
+
const [propertyName, modified] = property.getName().length !== 1
|
|
20
|
+
? [property.getName(), false]
|
|
21
|
+
: [`param${property.getName()}`, true];
|
|
22
|
+
const propertyType = property.getType().getText(property);
|
|
23
|
+
const propertyStructure = {
|
|
24
|
+
propertyName,
|
|
25
|
+
modified,
|
|
26
|
+
originalName: property.getName(),
|
|
27
|
+
type: ["string", "boolean"].includes(propertyType)
|
|
28
|
+
? propertyType
|
|
29
|
+
: "data",
|
|
30
|
+
required: property.getType().isNullable(),
|
|
31
|
+
inputFieldName: propertyName,
|
|
32
|
+
};
|
|
33
|
+
propertyStructures.push(propertyStructure);
|
|
34
|
+
});
|
|
51
35
|
}
|
|
52
36
|
else {
|
|
53
37
|
const propertyType = parameter.getType().getText(parameter);
|
|
@@ -65,7 +49,8 @@ exports.getActionMethodInputProperties = (parameter, parameterTypeDefinition) =>
|
|
|
65
49
|
}
|
|
66
50
|
return propertyStructures;
|
|
67
51
|
};
|
|
68
|
-
exports.
|
|
52
|
+
exports.getActionMethodInputProperties = getActionMethodInputProperties;
|
|
53
|
+
const writeInputs = async ({ inputsFile }, inputs) => {
|
|
69
54
|
inputs.forEach((propertyStructure) => {
|
|
70
55
|
const placeholder = inputsFile.addVariableStatement({
|
|
71
56
|
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
@@ -79,7 +64,7 @@ exports.writeInputs = ({ inputsFile }, inputs) => __awaiter(void 0, void 0, void
|
|
|
79
64
|
object.addPropertyAssignments([
|
|
80
65
|
{
|
|
81
66
|
name: "label",
|
|
82
|
-
initializer: `"${camelcase_1.default(propertyStructure.propertyName, {
|
|
67
|
+
initializer: `"${(0, camelcase_1.default)(propertyStructure.propertyName, {
|
|
83
68
|
pascalCase: true,
|
|
84
69
|
})}"`,
|
|
85
70
|
},
|
|
@@ -104,5 +89,5 @@ exports.writeInputs = ({ inputsFile }, inputs) => __awaiter(void 0, void 0, void
|
|
|
104
89
|
});
|
|
105
90
|
placeholder.remove();
|
|
106
91
|
});
|
|
107
|
-
}
|
|
108
|
-
|
|
92
|
+
};
|
|
93
|
+
exports.writeInputs = writeInputs;
|
package/lib/generate/parse.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -57,56 +61,46 @@ const getOpenApiMethods = (servicesPath, componentProject) => {
|
|
|
57
61
|
process.exit(1);
|
|
58
62
|
}
|
|
59
63
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.getType()
|
|
84
|
-
.getUnionTypes()
|
|
85
|
-
.every((type) => ["string", "boolean", "number", "any"].includes(type.getText()) ||
|
|
86
|
-
type.isObject() ||
|
|
87
|
-
type.isLiteral())) {
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
return componentProject.getSourceFileOrThrow(path.join(projectRoot, definitionDirectory, "models", `${camelcase_1.default(parameter.getName(), {
|
|
91
|
-
pascalCase: true,
|
|
92
|
-
})}.ts`));
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.error("Not implemented");
|
|
96
|
-
process.exit(1);
|
|
64
|
+
const isPrimitiveType = (type) => type.isObject() ||
|
|
65
|
+
type.isLiteral() ||
|
|
66
|
+
type.isString() ||
|
|
67
|
+
type.isBoolean() ||
|
|
68
|
+
type.isNumber() ||
|
|
69
|
+
type.isAny() ||
|
|
70
|
+
type.isUndefined();
|
|
71
|
+
const getParamTypeDefinition = (project, parameter) => {
|
|
72
|
+
const { componentProject, projectType, projectRoot, definitionDirectory } = project;
|
|
73
|
+
if (projectType === "wsdl") {
|
|
74
|
+
const paramName = parameter.getName();
|
|
75
|
+
return componentProject.getSourceFile(path.join(projectRoot, definitionDirectory, "definitions", `${(0, camelcase_1.default)(!paramName.includes("Param")
|
|
76
|
+
? paramName
|
|
77
|
+
: paramName.split("Param")[0], {
|
|
78
|
+
pascalCase: true,
|
|
79
|
+
})}.ts`));
|
|
80
|
+
}
|
|
81
|
+
else if (projectType === "openApi") {
|
|
82
|
+
// The OpenAPI generator skips certain types
|
|
83
|
+
const paramType = parameter.getType();
|
|
84
|
+
if (isPrimitiveType(paramType) ||
|
|
85
|
+
paramType.getUnionTypes().every(isPrimitiveType)) {
|
|
86
|
+
return undefined;
|
|
97
87
|
}
|
|
88
|
+
return componentProject.getSourceFile(path.join(projectRoot, definitionDirectory, "models", `${(0, camelcase_1.default)(parameter.getName(), {
|
|
89
|
+
pascalCase: true,
|
|
90
|
+
})}.ts`));
|
|
98
91
|
}
|
|
99
|
-
|
|
100
|
-
console.error("
|
|
92
|
+
else {
|
|
93
|
+
console.error("Not implemented");
|
|
101
94
|
process.exit(1);
|
|
102
95
|
}
|
|
103
96
|
};
|
|
97
|
+
exports.getParamTypeDefinition = getParamTypeDefinition;
|
|
104
98
|
// Gather the methods that will be translated to actions
|
|
105
|
-
|
|
99
|
+
const getActionMethods = (projectStructure) => {
|
|
106
100
|
const { projectRoot, componentProject, projectTemplateName, definitionDirectory, } = projectStructure;
|
|
107
101
|
let serviceMethods = {};
|
|
108
102
|
if (projectStructure.projectType === "wsdl") {
|
|
109
|
-
const methods = getWSDLClientMethods(path.join(projectRoot, definitionDirectory, "client.ts"), `${camelcase_1.default(projectTemplateName, { pascalCase: true })}Client`, componentProject);
|
|
103
|
+
const methods = getWSDLClientMethods(path.join(projectRoot, definitionDirectory, "client.ts"), `${(0, camelcase_1.default)(projectTemplateName, { pascalCase: true })}Client`, componentProject);
|
|
110
104
|
serviceMethods["createClientAsync"] = methods;
|
|
111
105
|
}
|
|
112
106
|
else if (projectStructure.projectType === "openApi") {
|
|
@@ -114,4 +108,4 @@ exports.getActionMethods = (projectStructure) => {
|
|
|
114
108
|
}
|
|
115
109
|
return serviceMethods;
|
|
116
110
|
};
|
|
117
|
-
|
|
111
|
+
exports.getActionMethods = getActionMethods;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
14
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
19
|
if (mod && mod.__esModule) return mod;
|
|
16
20
|
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
22
|
__setModuleDefault(result, mod);
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
@@ -84,7 +88,7 @@ const projectTypeSetup = (project, projectType) => {
|
|
|
84
88
|
project.projectTemplatePath = openApiPath;
|
|
85
89
|
}
|
|
86
90
|
};
|
|
87
|
-
|
|
91
|
+
const initializeProject = (projectRoot, projectTemplateName, projectTemplatePath, projectType, includeClient, addRetry) => {
|
|
88
92
|
const componentProject = new ts_morph_1.Project({
|
|
89
93
|
tsConfigFilePath: path.join(projectRoot, "tsconfig.json"),
|
|
90
94
|
});
|
|
@@ -92,13 +96,13 @@ exports.initializeProject = (projectRoot, projectTemplateName, projectTemplatePa
|
|
|
92
96
|
const actionFile = initializeActionFile(componentProject, projectRoot);
|
|
93
97
|
const inputsFile = initializeInputsFile(componentProject, projectRoot);
|
|
94
98
|
if (projectType === "openApi" && inputsFile) {
|
|
95
|
-
util_1.addRequiredInputs(projectType, inputsFile, addRetry);
|
|
99
|
+
(0, util_1.addRequiredInputs)(projectType, inputsFile, addRetry);
|
|
96
100
|
}
|
|
97
101
|
const project = {
|
|
98
102
|
projectRoot,
|
|
99
|
-
projectTemplateName: camelcase_1.default(projectTemplateName),
|
|
103
|
+
projectTemplateName: (0, camelcase_1.default)(projectTemplateName),
|
|
100
104
|
definitionDirectory: projectType === "wsdl"
|
|
101
|
-
? camelcase_1.default(projectTemplateName).toLowerCase()
|
|
105
|
+
? (0, camelcase_1.default)(projectTemplateName).toLowerCase()
|
|
102
106
|
: projectTemplateName,
|
|
103
107
|
projectTemplatePath,
|
|
104
108
|
projectType,
|
|
@@ -116,4 +120,4 @@ exports.initializeProject = (projectRoot, projectTemplateName, projectTemplatePa
|
|
|
116
120
|
projectTypeSetup(project, projectType);
|
|
117
121
|
return project;
|
|
118
122
|
};
|
|
119
|
-
|
|
123
|
+
exports.initializeProject = initializeProject;
|
package/lib/generate/util.js
CHANGED
|
@@ -6,15 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.appendRequiredFields = exports.addRequiredInputs = exports.createDescription = void 0;
|
|
7
7
|
const striptags_1 = __importDefault(require("striptags"));
|
|
8
8
|
const ts_morph_1 = require("ts-morph");
|
|
9
|
-
|
|
9
|
+
const createDescription = (text) => {
|
|
10
10
|
if (!text) {
|
|
11
11
|
return "";
|
|
12
12
|
}
|
|
13
|
-
const strippedText = striptags_1.default(text);
|
|
13
|
+
const strippedText = (0, striptags_1.default)(text);
|
|
14
14
|
const [nonEmptyLine] = strippedText.split("\n").filter((t) => t.trim() != "");
|
|
15
15
|
const [fragment] = nonEmptyLine.split(/[.!?]/g);
|
|
16
16
|
return fragment.replace(/`/g, "'");
|
|
17
17
|
};
|
|
18
|
+
exports.createDescription = createDescription;
|
|
18
19
|
const addProperty = (inputsFile, inputName, propertyList) => {
|
|
19
20
|
const placeholder = inputsFile.addVariableStatement({
|
|
20
21
|
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
@@ -33,14 +34,14 @@ const addProperty = (inputsFile, inputName, propertyList) => {
|
|
|
33
34
|
});
|
|
34
35
|
placeholder.remove();
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
+
const addRequiredInputs = (projectType, inputsFile, addRetry) => {
|
|
37
38
|
addProperty(inputsFile, "apiBaseUrl", [
|
|
38
39
|
{ name: `"label"`, initializer: `"API Base URL"` },
|
|
39
40
|
{ name: `"type"`, initializer: `"string"` },
|
|
40
41
|
{ name: `"required"`, initializer: `false` },
|
|
41
42
|
{
|
|
42
43
|
name: `"comments"`,
|
|
43
|
-
initializer: `"An optional url you can specify to
|
|
44
|
+
initializer: `"An optional url you can specify to override the default provided by the OpenAPI spec."`,
|
|
44
45
|
},
|
|
45
46
|
]);
|
|
46
47
|
addProperty(inputsFile, "debugRequest", [
|
|
@@ -86,7 +87,7 @@ exports.addRequiredInputs = (projectType, inputsFile, addRetry) => {
|
|
|
86
87
|
{ name: `"required"`, initializer: `false` },
|
|
87
88
|
{
|
|
88
89
|
name: `"comments"`,
|
|
89
|
-
initializer: `"An optional boolean that will have the client retry the request,
|
|
90
|
+
initializer: `"An optional boolean that will have the client retry the request, regardless of what type of error is thrown."`,
|
|
90
91
|
},
|
|
91
92
|
]);
|
|
92
93
|
addProperty(inputsFile, "useExponentialBackoff", [
|
|
@@ -101,7 +102,8 @@ exports.addRequiredInputs = (projectType, inputsFile, addRetry) => {
|
|
|
101
102
|
}
|
|
102
103
|
return inputsFile;
|
|
103
104
|
};
|
|
104
|
-
exports.
|
|
105
|
+
exports.addRequiredInputs = addRequiredInputs;
|
|
106
|
+
const appendRequiredFields = ({ inputFields, addRetry, includeClient, }) => {
|
|
105
107
|
if (!includeClient) {
|
|
106
108
|
return inputFields;
|
|
107
109
|
}
|
|
@@ -116,4 +118,4 @@ exports.appendRequiredFields = ({ inputFields, addRetry, includeClient, }) => {
|
|
|
116
118
|
]
|
|
117
119
|
: base;
|
|
118
120
|
};
|
|
119
|
-
|
|
121
|
+
exports.appendRequiredFields = appendRequiredFields;
|
package/lib/graphql.js
CHANGED
|
@@ -1,70 +1,42 @@
|
|
|
1
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
|
-
var _a;
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.gql = exports.
|
|
17
|
-
const
|
|
18
|
-
const apollo_client_1 = require("apollo-client");
|
|
19
|
-
const apollo_link_1 = require("apollo-link");
|
|
20
|
-
const apollo_link_context_1 = require("apollo-link-context");
|
|
21
|
-
const apollo_link_http_1 = require("apollo-link-http");
|
|
22
|
-
const apollo_cache_inmemory_1 = require("apollo-cache-inmemory");
|
|
23
|
-
const graphql_utils_1 = require("@prismatic-io/graphql-utils");
|
|
3
|
+
exports.gql = exports.gqlRequest = void 0;
|
|
4
|
+
const graphql_request_1 = require("graphql-request");
|
|
24
5
|
const auth_1 = require("./auth");
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
const isErrored = (result) => {
|
|
7
|
+
if (!(Boolean(result) &&
|
|
8
|
+
typeof result === "object" &&
|
|
9
|
+
result !== null &&
|
|
10
|
+
"errors" in result)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const assumed = result;
|
|
14
|
+
return Boolean(assumed.errors) && assumed.errors.length > 0;
|
|
15
|
+
};
|
|
16
|
+
const formatError = (field, messages) => {
|
|
17
|
+
const message = messages.join("\n");
|
|
18
|
+
if (field === "__all__") {
|
|
19
|
+
return message;
|
|
20
|
+
}
|
|
21
|
+
return `${field}: ${message}`;
|
|
22
|
+
};
|
|
23
|
+
const gqlRequest = async ({ document, variables, }) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const prismaticUri = (_a = process.env.PRISMATIC_URL) !== null && _a !== void 0 ? _a : "https://app.prismatic.io";
|
|
26
|
+
const accessToken = await (0, auth_1.getAccessToken)();
|
|
27
|
+
const result = await (0, graphql_request_1.request)(`${prismaticUri}/api`, document, variables, {
|
|
28
|
+
Authorization: `Bearer ${accessToken}`,
|
|
29
|
+
"Prismatic-Client": "prism",
|
|
30
|
+
});
|
|
31
|
+
const errors = Object.values(result)
|
|
32
|
+
.filter(isErrored)
|
|
33
|
+
.flatMap(({ errors }) => errors)
|
|
34
|
+
.map(({ field, messages }) => formatError(field, messages));
|
|
44
35
|
if (errors.length > 0) {
|
|
45
|
-
errors.
|
|
46
|
-
const label = !field || field === "__all__" ? "Error" : field;
|
|
47
|
-
console.error(`${label}: ${message}`);
|
|
48
|
-
});
|
|
49
|
-
process.exit(1);
|
|
36
|
+
throw new Error(errors.join("\n"));
|
|
50
37
|
}
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// FIXME: What should this actually be...? ALB requires it for HTTPS calls.
|
|
57
|
-
Referer: prismaticUri,
|
|
58
|
-
},
|
|
59
|
-
fetch: node_fetch_1.default,
|
|
60
|
-
});
|
|
61
|
-
exports.unauthedClient = new apollo_client_1.ApolloClient({
|
|
62
|
-
link: grapheneErrorLink.concat(httpLink),
|
|
63
|
-
cache: new apollo_cache_inmemory_1.InMemoryCache(),
|
|
64
|
-
});
|
|
65
|
-
exports.client = new apollo_client_1.ApolloClient({
|
|
66
|
-
link: authContext.concat(grapheneErrorLink).concat(httpLink),
|
|
67
|
-
cache: new apollo_cache_inmemory_1.InMemoryCache(),
|
|
68
|
-
});
|
|
69
|
-
exports.default = exports.client;
|
|
70
|
-
//# sourceMappingURL=graphql.js.map
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
exports.gqlRequest = gqlRequest;
|
|
41
|
+
var graphql_request_2 = require("graphql-request");
|
|
42
|
+
Object.defineProperty(exports, "gql", { enumerable: true, get: function () { return graphql_request_2.gql; } });
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.run = void 0;
|
|
4
|
+
var core_1 = require("@oclif/core");
|
|
5
|
+
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|