@prismatic-io/prism 3.3.0 → 4.2.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 +183 -201
- 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 +89 -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 +142 -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 +11 -68
- 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 +15 -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 +43 -100
- package/lib/generate/index.js +27 -23
- package/lib/generate/input.js +28 -43
- package/lib/generate/parse.js +18 -76
- package/lib/generate/sourceFile.js +15 -44
- package/lib/generate/util.js +4 -106
- 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 +24 -0
- package/oclif.manifest.json +1 -1
- package/package.json +50 -58
- 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 +0 -98
- package/lib/generate/client.js.map +0 -1
- package/lib/generate/connection.js +0 -86
- 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/assets/icon.png +0 -0
- package/templates/component/jest.config.js +0 -4
- package/templates/component/openapi/client.ts +0 -73
- package/templates/component/openapi/request.ts +0 -161
- 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/action.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,19 +18,10 @@ 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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
27
|
};
|
|
@@ -49,45 +44,19 @@ const getPerformFunctionWSDL = (projectTemplatePath, action) => {
|
|
|
49
44
|
})
|
|
50
45
|
.join(",")});`;
|
|
51
46
|
};
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
return `const result = await ${service}.${methodSignature.getName()}(${propertiesText});`;
|
|
56
|
-
};
|
|
57
|
-
const instantiatePerformFunction = (action, project, includeClient, addRetry) => {
|
|
58
|
-
const { projectTemplatePath, projectType } = project;
|
|
59
|
-
const clientCallParams = util_1.appendRequiredFields({
|
|
60
|
-
inputFields: ["connection"],
|
|
61
|
-
addRetry,
|
|
62
|
-
includeClient,
|
|
63
|
-
});
|
|
64
|
-
const clientCall = `initializeClient({ ${clientCallParams.join(", ")} });`;
|
|
65
|
-
let performFunction;
|
|
66
|
-
if (projectType === "wsdl") {
|
|
67
|
-
performFunction = getPerformFunctionWSDL(projectTemplatePath, action);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
performFunction = getPerformFunctionOpenApi(action);
|
|
71
|
-
}
|
|
47
|
+
const instantiatePerformFunction = (action, project) => {
|
|
48
|
+
const { projectTemplatePath } = project;
|
|
49
|
+
const performFunction = getPerformFunctionWSDL(projectTemplatePath, action);
|
|
72
50
|
const performParams = action.actionObject.inputs
|
|
73
51
|
.filter(({ shouldImport }) => shouldImport)
|
|
74
52
|
.map(({ properties, shouldImport }) => {
|
|
75
53
|
const name = properties.map(({ propertyName }) => propertyName).join(",");
|
|
76
54
|
return shouldImport ? name : "";
|
|
77
55
|
});
|
|
78
|
-
const updatedPerformParams =
|
|
79
|
-
inputFields: includeClient
|
|
80
|
-
? ["connection", ...performParams]
|
|
81
|
-
: projectType === "wsdl"
|
|
82
|
-
? [...performParams, "headers"]
|
|
83
|
-
: performParams,
|
|
84
|
-
addRetry,
|
|
85
|
-
includeClient,
|
|
86
|
-
});
|
|
56
|
+
const updatedPerformParams = [...performParams, "headers"];
|
|
87
57
|
return `async ({logger}, ${updatedPerformParams.length > 0
|
|
88
58
|
? `{ ${updatedPerformParams.join(", ")} }: Record<string,any>`
|
|
89
59
|
: ""}) => {
|
|
90
|
-
${projectType === "openApi" && includeClient ? clientCall : ""}
|
|
91
60
|
${performFunction}
|
|
92
61
|
return {data: result};
|
|
93
62
|
}`;
|
|
@@ -100,8 +69,8 @@ const generateActionObject = (methodSignature, project) => {
|
|
|
100
69
|
.map((parameter) => {
|
|
101
70
|
const input = {
|
|
102
71
|
name: parameter.getName(),
|
|
103
|
-
properties: input_1.getActionMethodInputProperties(parameter, parse_1.getParamTypeDefinition(project, parameter)),
|
|
104
|
-
paramTypeDefinition: parse_1.getParamTypeDefinition(project, parameter),
|
|
72
|
+
properties: (0, input_1.getActionMethodInputProperties)(parameter, (0, parse_1.getParamTypeDefinition)(project, parameter)),
|
|
73
|
+
paramTypeDefinition: (0, parse_1.getParamTypeDefinition)(project, parameter),
|
|
105
74
|
};
|
|
106
75
|
input.shouldImport =
|
|
107
76
|
(input.properties.length > 0 &&
|
|
@@ -120,9 +89,9 @@ const compileAction = (actionService, actionMethod, project) => {
|
|
|
120
89
|
var _a;
|
|
121
90
|
return ({
|
|
122
91
|
service: actionService,
|
|
123
|
-
key: camelcase_1.default(actionMethod.getName()),
|
|
92
|
+
key: (0, camelcase_1.default)(actionMethod.getName()),
|
|
124
93
|
display: {
|
|
125
|
-
label: camelcase_1.default(actionMethod.getName(), { pascalCase: true })
|
|
94
|
+
label: (0, camelcase_1.default)(actionMethod.getName(), { pascalCase: true })
|
|
126
95
|
.split(/(?=[A-Z])/)
|
|
127
96
|
.join(" "),
|
|
128
97
|
description: ((_a = actionMethod.getJsDocs()) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
@@ -133,7 +102,7 @@ const compileAction = (actionService, actionMethod, project) => {
|
|
|
133
102
|
actionObject: generateActionObject(actionMethod, project),
|
|
134
103
|
});
|
|
135
104
|
};
|
|
136
|
-
const writeAction = (action, project
|
|
105
|
+
const writeAction = async (action, project) => {
|
|
137
106
|
const { actionFile } = project;
|
|
138
107
|
// Apparently you can't generate an Object without adding it to the file
|
|
139
108
|
// so this is our place holder to use as a template
|
|
@@ -152,41 +121,29 @@ const writeAction = (action, project, includeClient, addRetry) => __awaiter(void
|
|
|
152
121
|
}
|
|
153
122
|
return shouldImport ? [name] : [];
|
|
154
123
|
});
|
|
155
|
-
const updatedInputFields = util_1.appendRequiredFields({
|
|
156
|
-
inputFields: includeClient
|
|
157
|
-
? [
|
|
158
|
-
`connection: { type: "connection", label: "connection", required: true }`,
|
|
159
|
-
...inputFields,
|
|
160
|
-
]
|
|
161
|
-
: inputFields,
|
|
162
|
-
includeClient,
|
|
163
|
-
addRetry,
|
|
164
|
-
});
|
|
165
124
|
object.addPropertyAssignments([
|
|
166
125
|
{
|
|
167
126
|
name: "display",
|
|
168
127
|
initializer: `{
|
|
169
128
|
label: "${action.display.label}",
|
|
170
|
-
description: \`${util_1.createDescription(action.display.description)}\`
|
|
129
|
+
description: \`${(0, util_1.createDescription)(action.display.description)}\`
|
|
171
130
|
}`,
|
|
172
131
|
},
|
|
173
132
|
{
|
|
174
133
|
name: "perform",
|
|
175
|
-
initializer: instantiatePerformFunction(action, project
|
|
134
|
+
initializer: instantiatePerformFunction(action, project),
|
|
176
135
|
},
|
|
177
136
|
{
|
|
178
137
|
name: "inputs",
|
|
179
|
-
initializer: `{${
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
`headers: {
|
|
138
|
+
initializer: `{${[
|
|
139
|
+
...inputFields,
|
|
140
|
+
`headers: {
|
|
183
141
|
label: "Headers",
|
|
184
142
|
type: "code",
|
|
185
143
|
comments: "Provide headers to the SOAP client",
|
|
186
144
|
default: '{}'
|
|
187
145
|
}`,
|
|
188
|
-
|
|
189
|
-
: [...updatedInputFields].join(", ")}}`,
|
|
146
|
+
]}}`,
|
|
190
147
|
},
|
|
191
148
|
]);
|
|
192
149
|
//Add the action payload to the action
|
|
@@ -203,63 +160,49 @@ const writeAction = (action, project, includeClient, addRetry) => __awaiter(void
|
|
|
203
160
|
// Remove the temporary action object now that we've placed our payload
|
|
204
161
|
// into the action
|
|
205
162
|
placeholder.remove();
|
|
206
|
-
}
|
|
207
|
-
const writeServicesImport = (services, { actionFile, definitionDirectory }) =>
|
|
163
|
+
};
|
|
164
|
+
const writeServicesImport = async (services, { actionFile, definitionDirectory }) => {
|
|
208
165
|
actionFile.addImportDeclaration({
|
|
209
166
|
moduleSpecifier: `../${definitionDirectory}/index`,
|
|
210
167
|
namedImports: services,
|
|
211
168
|
});
|
|
212
|
-
}
|
|
213
|
-
const writeInputsImport = (inputNames, { actionFile }) =>
|
|
169
|
+
};
|
|
170
|
+
const writeInputsImport = async (inputNames, { actionFile }) => {
|
|
214
171
|
actionFile.addImportDeclaration({
|
|
215
172
|
moduleSpecifier: "./inputs",
|
|
216
173
|
namedImports: inputNames,
|
|
217
174
|
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
moduleSpecifier: `./client`,
|
|
225
|
-
namedImports: ["initializeClient"],
|
|
226
|
-
},
|
|
227
|
-
]);
|
|
228
|
-
}
|
|
229
|
-
const methods = parse_1.getActionMethods(project);
|
|
230
|
-
const actions = lodash_1.sortBy(Object.entries(methods).flatMap(([service, actionMethods]) => {
|
|
231
|
-
const dedupedActions = lodash_1.uniqBy(actionMethods, (a) => a.getName());
|
|
175
|
+
};
|
|
176
|
+
const generateActions = async (project) => {
|
|
177
|
+
const { actionFile, inputsFile } = project;
|
|
178
|
+
const methods = (0, parse_1.getActionMethods)(project);
|
|
179
|
+
const actions = (0, lodash_1.sortBy)(Object.entries(methods).flatMap(([service, actionMethods]) => {
|
|
180
|
+
const dedupedActions = (0, lodash_1.uniqBy)(actionMethods, (a) => a.getName());
|
|
232
181
|
return dedupedActions.map((action) => compileAction(service, action, project));
|
|
233
182
|
}), ({ key }) => key);
|
|
234
183
|
const inputs = actions
|
|
235
184
|
.flatMap(({ actionObject }) => actionObject.inputs)
|
|
236
185
|
.filter(({ shouldImport }) => shouldImport)
|
|
237
186
|
.flatMap(({ properties }) => properties);
|
|
238
|
-
const dedupedInputs = lodash_1.sortBy(lodash_1.uniqBy(inputs, (i) => i.propertyName.toLowerCase()), (i) => i.propertyName);
|
|
239
|
-
|
|
187
|
+
const dedupedInputs = (0, lodash_1.sortBy)((0, lodash_1.uniqBy)(inputs, (i) => i.propertyName.toLowerCase()), (i) => i.propertyName);
|
|
188
|
+
await (0, input_1.writeInputs)(project, dedupedInputs);
|
|
240
189
|
inputsFile.organizeImports();
|
|
241
190
|
inputsFile.formatText();
|
|
242
|
-
|
|
191
|
+
await inputsFile.save();
|
|
243
192
|
const services = actions.map(({ service }) => service);
|
|
244
|
-
const dedupedServices = lodash_1.sortBy(lodash_1.uniq(services));
|
|
245
|
-
|
|
193
|
+
const dedupedServices = (0, lodash_1.sortBy)((0, lodash_1.uniq)(services));
|
|
194
|
+
await writeServicesImport(dedupedServices, project);
|
|
246
195
|
const inputNames = dedupedInputs.map(({ propertyName }) => propertyName);
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
addRetry,
|
|
252
|
-
})) || []
|
|
253
|
-
: inputNames, project);
|
|
254
|
-
const actionPromises = actions.map((action) => writeAction(action, project, includeClient, projectType === "openApi" && addRetry));
|
|
255
|
-
yield Promise.all(actionPromises);
|
|
256
|
-
const actionExports = lodash_1.sortBy(actions.map(({ key }) => key));
|
|
196
|
+
await writeInputsImport(inputNames, project);
|
|
197
|
+
const actionPromises = actions.map((action) => writeAction(action, project));
|
|
198
|
+
await Promise.all(actionPromises);
|
|
199
|
+
const actionExports = (0, lodash_1.sortBy)(actions.map(({ key }) => key));
|
|
257
200
|
actionFile.addExportAssignment({
|
|
258
201
|
isExportEquals: false,
|
|
259
202
|
expression: `{${actionExports.join(",\n")}}`,
|
|
260
203
|
});
|
|
261
204
|
actionFile.organizeImports();
|
|
262
205
|
actionFile.formatText();
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
|
|
206
|
+
await actionFile.save();
|
|
207
|
+
};
|
|
208
|
+
exports.generateActions = generateActions;
|
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,37 @@ 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
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
33
|
+
const prettier_1 = __importDefault(require("prettier"));
|
|
34
|
+
const fs_extra_1 = require("fs-extra");
|
|
35
|
+
const generate = async ({ projectRoot, projectTemplateName, projectTemplatePath, }) => {
|
|
38
36
|
var _a;
|
|
39
|
-
const project = sourceFile_1.initializeProject(projectRoot, projectTemplateName, projectTemplatePath
|
|
37
|
+
const project = (0, sourceFile_1.initializeProject)(projectRoot, projectTemplateName, projectTemplatePath);
|
|
40
38
|
const { componentProject } = project;
|
|
41
|
-
|
|
42
|
-
yield client_1.generateClient(project);
|
|
43
|
-
yield connection_1.generateConnections(project);
|
|
44
|
-
}
|
|
45
|
-
yield action_1.generateActions(project, includeClient, projectType === "openApi" && addRetry);
|
|
39
|
+
await (0, action_1.generateActions)(project);
|
|
46
40
|
(_a = componentProject
|
|
47
41
|
.getSourceFile(path.join(projectRoot, "src", "index.test.ts"))) === null || _a === void 0 ? void 0 : _a.delete();
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
42
|
+
await componentProject.save();
|
|
43
|
+
};
|
|
44
|
+
exports.generate = generate;
|
|
45
|
+
const updatePackageJson = async ({ path, dependencies = {}, devDependencies = {}, }) => {
|
|
46
|
+
const contents = await (0, fs_extra_1.readJson)(path, { encoding: "utf-8" });
|
|
47
|
+
Object.assign(contents.dependencies, dependencies);
|
|
48
|
+
Object.assign(contents.devDependencies, devDependencies);
|
|
49
|
+
const formatted = prettier_1.default.format(JSON.stringify(contents, null, 2), {
|
|
50
|
+
parser: "json",
|
|
51
|
+
});
|
|
52
|
+
await (0, fs_extra_1.writeFile)(path, formatted);
|
|
53
|
+
};
|
|
54
|
+
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
|
};
|
|
@@ -37,81 +41,19 @@ const getWSDLClientMethods = (clientPath, clientInterface, componentProject) =>
|
|
|
37
41
|
process.exit(1);
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let methods = [];
|
|
47
|
-
const serviceClass = serviceFile.getClassOrThrow(serviceFile.getBaseName().split(".ts")[0]);
|
|
48
|
-
methods = serviceClass
|
|
49
|
-
.getMethods()
|
|
50
|
-
.map((method) => method.getSignature().getDeclaration());
|
|
51
|
-
return [serviceClass.getNameOrThrow(), methods];
|
|
52
|
-
}));
|
|
53
|
-
return serviceToMethodsMapping;
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
console.error("Unable to find services directory." + error);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.getParamTypeDefinition = (project, parameter) => {
|
|
61
|
-
const { componentProject, projectType, projectRoot, definitionDirectory, } = project;
|
|
62
|
-
try {
|
|
63
|
-
if (projectType === "wsdl") {
|
|
64
|
-
const paramName = parameter.getName();
|
|
65
|
-
return componentProject.getSourceFileOrThrow(path.join(projectRoot, definitionDirectory, "definitions", `${camelcase_1.default(!paramName.includes("Param")
|
|
66
|
-
? paramName
|
|
67
|
-
: paramName.split("Param")[0], {
|
|
68
|
-
pascalCase: true,
|
|
69
|
-
})}.ts`));
|
|
70
|
-
}
|
|
71
|
-
else if (projectType === "openApi") {
|
|
72
|
-
//Base types and literal unions don't have definition files
|
|
73
|
-
parameter
|
|
74
|
-
.getType()
|
|
75
|
-
.getUnionTypes()
|
|
76
|
-
.every((type) => {
|
|
77
|
-
return (["string", "boolean", "number", "any"].includes(type.getText()) ||
|
|
78
|
-
type.isObject() ||
|
|
79
|
-
type.isLiteral());
|
|
80
|
-
});
|
|
81
|
-
if (["string", "boolean", "number"].includes(parameter.getType().getText(parameter)) ||
|
|
82
|
-
parameter
|
|
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);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
console.error("Unable to find parameter definition file" + error);
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
44
|
+
const getParamTypeDefinition = (project, parameter) => {
|
|
45
|
+
const { componentProject, projectRoot, definitionDirectory } = project;
|
|
46
|
+
const paramName = parameter.getName();
|
|
47
|
+
return componentProject.getSourceFile(path.join(projectRoot, definitionDirectory, "definitions", `${(0, camelcase_1.default)(!paramName.includes("Param") ? paramName : paramName.split("Param")[0], {
|
|
48
|
+
pascalCase: true,
|
|
49
|
+
})}.ts`));
|
|
103
50
|
};
|
|
51
|
+
exports.getParamTypeDefinition = getParamTypeDefinition;
|
|
104
52
|
// Gather the methods that will be translated to actions
|
|
105
|
-
|
|
53
|
+
const getActionMethods = (projectStructure) => {
|
|
106
54
|
const { projectRoot, componentProject, projectTemplateName, definitionDirectory, } = projectStructure;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
serviceMethods["createClientAsync"] = methods;
|
|
111
|
-
}
|
|
112
|
-
else if (projectStructure.projectType === "openApi") {
|
|
113
|
-
serviceMethods = getOpenApiMethods(path.join(projectRoot, definitionDirectory, "services"), componentProject);
|
|
114
|
-
}
|
|
115
|
-
return serviceMethods;
|
|
55
|
+
return {
|
|
56
|
+
createClientAsync: getWSDLClientMethods(path.join(projectRoot, definitionDirectory, "client.ts"), `${(0, camelcase_1.default)(projectTemplateName, { pascalCase: true })}Client`, componentProject),
|
|
57
|
+
};
|
|
116
58
|
};
|
|
117
|
-
|
|
59
|
+
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
|
};
|
|
@@ -26,7 +30,6 @@ exports.initializeProject = void 0;
|
|
|
26
30
|
const camelcase_1 = __importDefault(require("camelcase"));
|
|
27
31
|
const ts_morph_1 = require("ts-morph");
|
|
28
32
|
const path = __importStar(require("path"));
|
|
29
|
-
const util_1 = require("./util");
|
|
30
33
|
const initializeActionFile = (componentProject, projectRoot) => {
|
|
31
34
|
const actionFile = componentProject.createSourceFile(path.join(projectRoot, "src", "actions.ts"), undefined, { overwrite: true });
|
|
32
35
|
actionFile.addImportDeclaration({
|
|
@@ -35,14 +38,6 @@ const initializeActionFile = (componentProject, projectRoot) => {
|
|
|
35
38
|
});
|
|
36
39
|
return actionFile;
|
|
37
40
|
};
|
|
38
|
-
const initializeClientFile = (componentProject, projectRoot) => {
|
|
39
|
-
const clientFile = componentProject.createSourceFile(path.join(projectRoot, "src", "client.ts"), undefined, { overwrite: true });
|
|
40
|
-
return clientFile;
|
|
41
|
-
};
|
|
42
|
-
const initializeConnectionsFile = (componentProject, projectRoot) => {
|
|
43
|
-
const connectionsFile = componentProject.createSourceFile(path.join(projectRoot, "src", "connections.ts"), undefined, { overwrite: true });
|
|
44
|
-
return connectionsFile;
|
|
45
|
-
};
|
|
46
41
|
const initializeInputsFile = (componentProject, projectRoot) => {
|
|
47
42
|
const inputsFile = componentProject.createSourceFile(path.join(projectRoot, "src", "inputs.ts"), undefined, { overwrite: true });
|
|
48
43
|
inputsFile.addImportDeclaration({
|
|
@@ -56,12 +51,6 @@ const copyTemplateFileToProject = (componentProject, projectRoot, projectTemplat
|
|
|
56
51
|
const templateFile = componentProject.getSourceFileOrThrow(projectTemplatePath);
|
|
57
52
|
templateFile.copy(path.join(process.cwd(), projectRoot, fileName));
|
|
58
53
|
};
|
|
59
|
-
const initializeOpenApi = ({ projectRoot, projectTemplatePath, componentProject, }) => {
|
|
60
|
-
// Copy our template file into the component project
|
|
61
|
-
copyTemplateFileToProject(componentProject, projectRoot, projectTemplatePath, path.basename(projectTemplatePath));
|
|
62
|
-
// Return the relative path of the OpenAPI spec
|
|
63
|
-
return path.relative(path.join(projectRoot, "src"), path.join(projectRoot, path.basename(projectTemplatePath)));
|
|
64
|
-
};
|
|
65
54
|
const initializeWSDL = ({ projectRoot, projectTemplateName, projectTemplatePath, componentProject, actionFile, }) => {
|
|
66
55
|
const wsdlProjectLocation = path.join(projectRoot, `${projectTemplateName}.wsdl`);
|
|
67
56
|
// Copy the wsdl used for generation to the project root
|
|
@@ -73,47 +62,29 @@ const initializeWSDL = ({ projectRoot, projectTemplateName, projectTemplatePath,
|
|
|
73
62
|
// Return the relative path of the WSDL
|
|
74
63
|
return path.relative(path.join(projectRoot, "src"), wsdlProjectLocation);
|
|
75
64
|
};
|
|
76
|
-
const projectTypeSetup = (project
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
project.projectTemplatePath = wsdlPath;
|
|
81
|
-
}
|
|
82
|
-
else if (projectType === "openApi") {
|
|
83
|
-
const openApiPath = initializeOpenApi(project);
|
|
84
|
-
project.projectTemplatePath = openApiPath;
|
|
85
|
-
}
|
|
65
|
+
const projectTypeSetup = (project) => {
|
|
66
|
+
const wsdlPath = initializeWSDL(project);
|
|
67
|
+
// Update the WSDL Path to be in our component project
|
|
68
|
+
project.projectTemplatePath = wsdlPath;
|
|
86
69
|
};
|
|
87
|
-
|
|
70
|
+
const initializeProject = (projectRoot, projectTemplateName, projectTemplatePath) => {
|
|
88
71
|
const componentProject = new ts_morph_1.Project({
|
|
89
72
|
tsConfigFilePath: path.join(projectRoot, "tsconfig.json"),
|
|
90
73
|
});
|
|
91
74
|
componentProject.addSourceFilesAtPaths(path.join(projectRoot, "**/*"));
|
|
92
75
|
const actionFile = initializeActionFile(componentProject, projectRoot);
|
|
93
76
|
const inputsFile = initializeInputsFile(componentProject, projectRoot);
|
|
94
|
-
if (projectType === "openApi" && inputsFile) {
|
|
95
|
-
util_1.addRequiredInputs(projectType, inputsFile, addRetry);
|
|
96
|
-
}
|
|
97
77
|
const project = {
|
|
98
78
|
projectRoot,
|
|
99
|
-
projectTemplateName: camelcase_1.default(projectTemplateName),
|
|
100
|
-
definitionDirectory:
|
|
101
|
-
? camelcase_1.default(projectTemplateName).toLowerCase()
|
|
102
|
-
: projectTemplateName,
|
|
79
|
+
projectTemplateName: (0, camelcase_1.default)(projectTemplateName),
|
|
80
|
+
definitionDirectory: (0, camelcase_1.default)(projectTemplateName).toLowerCase(),
|
|
103
81
|
projectTemplatePath,
|
|
104
|
-
projectType,
|
|
105
82
|
componentProject,
|
|
106
83
|
actionFile,
|
|
107
84
|
inputsFile,
|
|
108
85
|
};
|
|
109
|
-
if (projectType === "openApi" && includeClient) {
|
|
110
|
-
const clientFile = initializeClientFile(componentProject, projectRoot);
|
|
111
|
-
project.clientFile = clientFile;
|
|
112
|
-
const connectionsFile = initializeConnectionsFile(componentProject, projectRoot);
|
|
113
|
-
project.connectionsFile = connectionsFile;
|
|
114
|
-
}
|
|
115
86
|
// Setup type specific project details
|
|
116
|
-
projectTypeSetup(project
|
|
87
|
+
projectTypeSetup(project);
|
|
117
88
|
return project;
|
|
118
89
|
};
|
|
119
|
-
|
|
90
|
+
exports.initializeProject = initializeProject;
|