@prismatic-io/prism 4.1.1 → 4.2.2
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/lib/commands/alerts/events/list.js +4 -1
- package/lib/commands/alerts/groups/list.js +23 -10
- package/lib/commands/alerts/monitors/list.js +41 -11
- package/lib/commands/alerts/webhooks/list.js +26 -13
- package/lib/commands/components/actions/list.js +60 -19
- package/lib/commands/components/dev/run.js +19 -5
- package/lib/commands/components/dev/test.js +1 -1
- package/lib/commands/components/init/index.js +39 -100
- package/lib/commands/components/list.js +42 -19
- package/lib/commands/components/triggers/list.js +61 -20
- package/lib/commands/customers/list.js +29 -11
- package/lib/commands/customers/users/list.js +34 -15
- package/lib/commands/instances/config-vars/list.js +44 -19
- package/lib/commands/instances/flow-configs/list.js +29 -16
- package/lib/commands/instances/list.js +45 -21
- package/lib/commands/integrations/flows/list.js +29 -16
- package/lib/commands/integrations/list.js +32 -15
- package/lib/commands/organization/users/list.js +37 -12
- package/lib/generate/action.js +14 -66
- package/lib/generate/index.js +3 -9
- package/lib/generate/parse.js +8 -60
- package/lib/generate/sourceFile.js +7 -40
- package/lib/generate/util.js +1 -105
- package/lib/yeoman.js +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +5 -7
- package/lib/generate/client.js +0 -93
- package/lib/generate/connection.js +0 -77
- package/templates/component/assets/icon.png +0 -0
- package/templates/component/openapi/client.ts +0 -75
- package/templates/component/openapi/request.ts +0 -163
package/lib/generate/action.js
CHANGED
|
@@ -44,45 +44,19 @@ const getPerformFunctionWSDL = (projectTemplatePath, action) => {
|
|
|
44
44
|
})
|
|
45
45
|
.join(",")});`;
|
|
46
46
|
};
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
return `const result = await ${service}.${methodSignature.getName()}(${propertiesText});`;
|
|
51
|
-
};
|
|
52
|
-
const instantiatePerformFunction = (action, project, includeClient, addRetry) => {
|
|
53
|
-
const { projectTemplatePath, projectType } = project;
|
|
54
|
-
const clientCallParams = (0, util_1.appendRequiredFields)({
|
|
55
|
-
inputFields: ["connection"],
|
|
56
|
-
addRetry,
|
|
57
|
-
includeClient,
|
|
58
|
-
});
|
|
59
|
-
const clientCall = `initializeClient({ ${clientCallParams.join(", ")} });`;
|
|
60
|
-
let performFunction;
|
|
61
|
-
if (projectType === "wsdl") {
|
|
62
|
-
performFunction = getPerformFunctionWSDL(projectTemplatePath, action);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
performFunction = getPerformFunctionOpenApi(action);
|
|
66
|
-
}
|
|
47
|
+
const instantiatePerformFunction = (action, project) => {
|
|
48
|
+
const { projectTemplatePath } = project;
|
|
49
|
+
const performFunction = getPerformFunctionWSDL(projectTemplatePath, action);
|
|
67
50
|
const performParams = action.actionObject.inputs
|
|
68
51
|
.filter(({ shouldImport }) => shouldImport)
|
|
69
52
|
.map(({ properties, shouldImport }) => {
|
|
70
53
|
const name = properties.map(({ propertyName }) => propertyName).join(",");
|
|
71
54
|
return shouldImport ? name : "";
|
|
72
55
|
});
|
|
73
|
-
const updatedPerformParams =
|
|
74
|
-
inputFields: includeClient
|
|
75
|
-
? ["connection", ...performParams]
|
|
76
|
-
: projectType === "wsdl"
|
|
77
|
-
? [...performParams, "headers"]
|
|
78
|
-
: performParams,
|
|
79
|
-
addRetry,
|
|
80
|
-
includeClient,
|
|
81
|
-
});
|
|
56
|
+
const updatedPerformParams = [...performParams, "headers"];
|
|
82
57
|
return `async ({logger}, ${updatedPerformParams.length > 0
|
|
83
58
|
? `{ ${updatedPerformParams.join(", ")} }: Record<string,any>`
|
|
84
59
|
: ""}) => {
|
|
85
|
-
${projectType === "openApi" && includeClient ? clientCall : ""}
|
|
86
60
|
${performFunction}
|
|
87
61
|
return {data: result};
|
|
88
62
|
}`;
|
|
@@ -128,7 +102,7 @@ const compileAction = (actionService, actionMethod, project) => {
|
|
|
128
102
|
actionObject: generateActionObject(actionMethod, project),
|
|
129
103
|
});
|
|
130
104
|
};
|
|
131
|
-
const writeAction = async (action, project
|
|
105
|
+
const writeAction = async (action, project) => {
|
|
132
106
|
const { actionFile } = project;
|
|
133
107
|
// Apparently you can't generate an Object without adding it to the file
|
|
134
108
|
// so this is our place holder to use as a template
|
|
@@ -147,16 +121,6 @@ const writeAction = async (action, project, includeClient, addRetry) => {
|
|
|
147
121
|
}
|
|
148
122
|
return shouldImport ? [name] : [];
|
|
149
123
|
});
|
|
150
|
-
const updatedInputFields = (0, util_1.appendRequiredFields)({
|
|
151
|
-
inputFields: includeClient
|
|
152
|
-
? [
|
|
153
|
-
`connection: { type: "connection", label: "connection", required: true }`,
|
|
154
|
-
...inputFields,
|
|
155
|
-
]
|
|
156
|
-
: inputFields,
|
|
157
|
-
includeClient,
|
|
158
|
-
addRetry,
|
|
159
|
-
});
|
|
160
124
|
object.addPropertyAssignments([
|
|
161
125
|
{
|
|
162
126
|
name: "display",
|
|
@@ -167,21 +131,19 @@ const writeAction = async (action, project, includeClient, addRetry) => {
|
|
|
167
131
|
},
|
|
168
132
|
{
|
|
169
133
|
name: "perform",
|
|
170
|
-
initializer: instantiatePerformFunction(action, project
|
|
134
|
+
initializer: instantiatePerformFunction(action, project),
|
|
171
135
|
},
|
|
172
136
|
{
|
|
173
137
|
name: "inputs",
|
|
174
|
-
initializer: `{${
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
`headers: {
|
|
138
|
+
initializer: `{${[
|
|
139
|
+
...inputFields,
|
|
140
|
+
`headers: {
|
|
178
141
|
label: "Headers",
|
|
179
142
|
type: "code",
|
|
180
143
|
comments: "Provide headers to the SOAP client",
|
|
181
144
|
default: '{}'
|
|
182
145
|
}`,
|
|
183
|
-
|
|
184
|
-
: [...updatedInputFields].join(", ")}}`,
|
|
146
|
+
]}}`,
|
|
185
147
|
},
|
|
186
148
|
]);
|
|
187
149
|
//Add the action payload to the action
|
|
@@ -211,16 +173,8 @@ const writeInputsImport = async (inputNames, { actionFile }) => {
|
|
|
211
173
|
namedImports: inputNames,
|
|
212
174
|
});
|
|
213
175
|
};
|
|
214
|
-
const generateActions = async (project
|
|
215
|
-
const {
|
|
216
|
-
if (projectType === "openApi" && includeClient) {
|
|
217
|
-
actionFile.addImportDeclarations([
|
|
218
|
-
{
|
|
219
|
-
moduleSpecifier: `./client`,
|
|
220
|
-
namedImports: ["initializeClient"],
|
|
221
|
-
},
|
|
222
|
-
]);
|
|
223
|
-
}
|
|
176
|
+
const generateActions = async (project) => {
|
|
177
|
+
const { actionFile, inputsFile } = project;
|
|
224
178
|
const methods = (0, parse_1.getActionMethods)(project);
|
|
225
179
|
const actions = (0, lodash_1.sortBy)(Object.entries(methods).flatMap(([service, actionMethods]) => {
|
|
226
180
|
const dedupedActions = (0, lodash_1.uniqBy)(actionMethods, (a) => a.getName());
|
|
@@ -239,14 +193,8 @@ const generateActions = async (project, includeClient, addRetry) => {
|
|
|
239
193
|
const dedupedServices = (0, lodash_1.sortBy)((0, lodash_1.uniq)(services));
|
|
240
194
|
await writeServicesImport(dedupedServices, project);
|
|
241
195
|
const inputNames = dedupedInputs.map(({ propertyName }) => propertyName);
|
|
242
|
-
await writeInputsImport(
|
|
243
|
-
|
|
244
|
-
inputFields: inputNames,
|
|
245
|
-
includeClient,
|
|
246
|
-
addRetry,
|
|
247
|
-
})) || []
|
|
248
|
-
: inputNames, project);
|
|
249
|
-
const actionPromises = actions.map((action) => writeAction(action, project, includeClient, projectType === "openApi" && addRetry));
|
|
196
|
+
await writeInputsImport(inputNames, project);
|
|
197
|
+
const actionPromises = actions.map((action) => writeAction(action, project));
|
|
250
198
|
await Promise.all(actionPromises);
|
|
251
199
|
const actionExports = (0, lodash_1.sortBy)(actions.map(({ key }) => key));
|
|
252
200
|
actionFile.addExportAssignment({
|
package/lib/generate/index.js
CHANGED
|
@@ -30,19 +30,13 @@ exports.updatePackageJson = exports.generate = void 0;
|
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const sourceFile_1 = require("./sourceFile");
|
|
32
32
|
const action_1 = require("./action");
|
|
33
|
-
const client_1 = require("./client");
|
|
34
|
-
const connection_1 = require("./connection");
|
|
35
33
|
const prettier_1 = __importDefault(require("prettier"));
|
|
36
34
|
const fs_extra_1 = require("fs-extra");
|
|
37
|
-
const generate = async ({ projectRoot, projectTemplateName, projectTemplatePath,
|
|
35
|
+
const generate = async ({ projectRoot, projectTemplateName, projectTemplatePath, }) => {
|
|
38
36
|
var _a;
|
|
39
|
-
const project = (0, sourceFile_1.initializeProject)(projectRoot, projectTemplateName, projectTemplatePath
|
|
37
|
+
const project = (0, sourceFile_1.initializeProject)(projectRoot, projectTemplateName, projectTemplatePath);
|
|
40
38
|
const { componentProject } = project;
|
|
41
|
-
|
|
42
|
-
await (0, client_1.generateClient)(project);
|
|
43
|
-
await (0, connection_1.generateConnections)(project);
|
|
44
|
-
}
|
|
45
|
-
await (0, 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
42
|
await componentProject.save();
|
package/lib/generate/parse.js
CHANGED
|
@@ -41,71 +41,19 @@ const getWSDLClientMethods = (clientPath, clientInterface, componentProject) =>
|
|
|
41
41
|
process.exit(1);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
const getOpenApiMethods = (servicesPath, componentProject) => {
|
|
45
|
-
try {
|
|
46
|
-
const servicesFiles = componentProject
|
|
47
|
-
.getDirectoryOrThrow(servicesPath)
|
|
48
|
-
.getSourceFiles();
|
|
49
|
-
const serviceToMethodsMapping = Object.fromEntries(servicesFiles.map((serviceFile) => {
|
|
50
|
-
let methods = [];
|
|
51
|
-
const serviceClass = serviceFile.getClassOrThrow(serviceFile.getBaseName().split(".ts")[0]);
|
|
52
|
-
methods = serviceClass
|
|
53
|
-
.getMethods()
|
|
54
|
-
.map((method) => method.getSignature().getDeclaration());
|
|
55
|
-
return [serviceClass.getNameOrThrow(), methods];
|
|
56
|
-
}));
|
|
57
|
-
return serviceToMethodsMapping;
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.error("Unable to find services directory." + error);
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
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
44
|
const getParamTypeDefinition = (project, parameter) => {
|
|
72
|
-
const { componentProject,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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;
|
|
87
|
-
}
|
|
88
|
-
return componentProject.getSourceFile(path.join(projectRoot, definitionDirectory, "models", `${(0, camelcase_1.default)(parameter.getName(), {
|
|
89
|
-
pascalCase: true,
|
|
90
|
-
})}.ts`));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
console.error("Not implemented");
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
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`));
|
|
96
50
|
};
|
|
97
51
|
exports.getParamTypeDefinition = getParamTypeDefinition;
|
|
98
52
|
// Gather the methods that will be translated to actions
|
|
99
53
|
const getActionMethods = (projectStructure) => {
|
|
100
54
|
const { projectRoot, componentProject, projectTemplateName, definitionDirectory, } = projectStructure;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
serviceMethods["createClientAsync"] = methods;
|
|
105
|
-
}
|
|
106
|
-
else if (projectStructure.projectType === "openApi") {
|
|
107
|
-
serviceMethods = getOpenApiMethods(path.join(projectRoot, definitionDirectory, "services"), componentProject);
|
|
108
|
-
}
|
|
109
|
-
return serviceMethods;
|
|
55
|
+
return {
|
|
56
|
+
createClientAsync: getWSDLClientMethods(path.join(projectRoot, definitionDirectory, "client.ts"), `${(0, camelcase_1.default)(projectTemplateName, { pascalCase: true })}Client`, componentProject),
|
|
57
|
+
};
|
|
110
58
|
};
|
|
111
59
|
exports.getActionMethods = getActionMethods;
|
|
@@ -30,7 +30,6 @@ exports.initializeProject = void 0;
|
|
|
30
30
|
const camelcase_1 = __importDefault(require("camelcase"));
|
|
31
31
|
const ts_morph_1 = require("ts-morph");
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
|
-
const util_1 = require("./util");
|
|
34
33
|
const initializeActionFile = (componentProject, projectRoot) => {
|
|
35
34
|
const actionFile = componentProject.createSourceFile(path.join(projectRoot, "src", "actions.ts"), undefined, { overwrite: true });
|
|
36
35
|
actionFile.addImportDeclaration({
|
|
@@ -39,14 +38,6 @@ const initializeActionFile = (componentProject, projectRoot) => {
|
|
|
39
38
|
});
|
|
40
39
|
return actionFile;
|
|
41
40
|
};
|
|
42
|
-
const initializeClientFile = (componentProject, projectRoot) => {
|
|
43
|
-
const clientFile = componentProject.createSourceFile(path.join(projectRoot, "src", "client.ts"), undefined, { overwrite: true });
|
|
44
|
-
return clientFile;
|
|
45
|
-
};
|
|
46
|
-
const initializeConnectionsFile = (componentProject, projectRoot) => {
|
|
47
|
-
const connectionsFile = componentProject.createSourceFile(path.join(projectRoot, "src", "connections.ts"), undefined, { overwrite: true });
|
|
48
|
-
return connectionsFile;
|
|
49
|
-
};
|
|
50
41
|
const initializeInputsFile = (componentProject, projectRoot) => {
|
|
51
42
|
const inputsFile = componentProject.createSourceFile(path.join(projectRoot, "src", "inputs.ts"), undefined, { overwrite: true });
|
|
52
43
|
inputsFile.addImportDeclaration({
|
|
@@ -60,12 +51,6 @@ const copyTemplateFileToProject = (componentProject, projectRoot, projectTemplat
|
|
|
60
51
|
const templateFile = componentProject.getSourceFileOrThrow(projectTemplatePath);
|
|
61
52
|
templateFile.copy(path.join(process.cwd(), projectRoot, fileName));
|
|
62
53
|
};
|
|
63
|
-
const initializeOpenApi = ({ projectRoot, projectTemplatePath, componentProject, }) => {
|
|
64
|
-
// Copy our template file into the component project
|
|
65
|
-
copyTemplateFileToProject(componentProject, projectRoot, projectTemplatePath, path.basename(projectTemplatePath));
|
|
66
|
-
// Return the relative path of the OpenAPI spec
|
|
67
|
-
return path.relative(path.join(projectRoot, "src"), path.join(projectRoot, path.basename(projectTemplatePath)));
|
|
68
|
-
};
|
|
69
54
|
const initializeWSDL = ({ projectRoot, projectTemplateName, projectTemplatePath, componentProject, actionFile, }) => {
|
|
70
55
|
const wsdlProjectLocation = path.join(projectRoot, `${projectTemplateName}.wsdl`);
|
|
71
56
|
// Copy the wsdl used for generation to the project root
|
|
@@ -77,47 +62,29 @@ const initializeWSDL = ({ projectRoot, projectTemplateName, projectTemplatePath,
|
|
|
77
62
|
// Return the relative path of the WSDL
|
|
78
63
|
return path.relative(path.join(projectRoot, "src"), wsdlProjectLocation);
|
|
79
64
|
};
|
|
80
|
-
const projectTypeSetup = (project
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
project.projectTemplatePath = wsdlPath;
|
|
85
|
-
}
|
|
86
|
-
else if (projectType === "openApi") {
|
|
87
|
-
const openApiPath = initializeOpenApi(project);
|
|
88
|
-
project.projectTemplatePath = openApiPath;
|
|
89
|
-
}
|
|
65
|
+
const projectTypeSetup = (project) => {
|
|
66
|
+
const wsdlPath = initializeWSDL(project);
|
|
67
|
+
// Update the WSDL Path to be in our component project
|
|
68
|
+
project.projectTemplatePath = wsdlPath;
|
|
90
69
|
};
|
|
91
|
-
const initializeProject = (projectRoot, projectTemplateName, projectTemplatePath
|
|
70
|
+
const initializeProject = (projectRoot, projectTemplateName, projectTemplatePath) => {
|
|
92
71
|
const componentProject = new ts_morph_1.Project({
|
|
93
72
|
tsConfigFilePath: path.join(projectRoot, "tsconfig.json"),
|
|
94
73
|
});
|
|
95
74
|
componentProject.addSourceFilesAtPaths(path.join(projectRoot, "**/*"));
|
|
96
75
|
const actionFile = initializeActionFile(componentProject, projectRoot);
|
|
97
76
|
const inputsFile = initializeInputsFile(componentProject, projectRoot);
|
|
98
|
-
if (projectType === "openApi" && inputsFile) {
|
|
99
|
-
(0, util_1.addRequiredInputs)(projectType, inputsFile, addRetry);
|
|
100
|
-
}
|
|
101
77
|
const project = {
|
|
102
78
|
projectRoot,
|
|
103
79
|
projectTemplateName: (0, camelcase_1.default)(projectTemplateName),
|
|
104
|
-
definitionDirectory:
|
|
105
|
-
? (0, camelcase_1.default)(projectTemplateName).toLowerCase()
|
|
106
|
-
: projectTemplateName,
|
|
80
|
+
definitionDirectory: (0, camelcase_1.default)(projectTemplateName).toLowerCase(),
|
|
107
81
|
projectTemplatePath,
|
|
108
|
-
projectType,
|
|
109
82
|
componentProject,
|
|
110
83
|
actionFile,
|
|
111
84
|
inputsFile,
|
|
112
85
|
};
|
|
113
|
-
if (projectType === "openApi" && includeClient) {
|
|
114
|
-
const clientFile = initializeClientFile(componentProject, projectRoot);
|
|
115
|
-
project.clientFile = clientFile;
|
|
116
|
-
const connectionsFile = initializeConnectionsFile(componentProject, projectRoot);
|
|
117
|
-
project.connectionsFile = connectionsFile;
|
|
118
|
-
}
|
|
119
86
|
// Setup type specific project details
|
|
120
|
-
projectTypeSetup(project
|
|
87
|
+
projectTypeSetup(project);
|
|
121
88
|
return project;
|
|
122
89
|
};
|
|
123
90
|
exports.initializeProject = initializeProject;
|
package/lib/generate/util.js
CHANGED
|
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createDescription = void 0;
|
|
7
7
|
const striptags_1 = __importDefault(require("striptags"));
|
|
8
|
-
const ts_morph_1 = require("ts-morph");
|
|
9
8
|
const createDescription = (text) => {
|
|
10
9
|
if (!text) {
|
|
11
10
|
return "";
|
|
@@ -16,106 +15,3 @@ const createDescription = (text) => {
|
|
|
16
15
|
return fragment.replace(/`/g, "'");
|
|
17
16
|
};
|
|
18
17
|
exports.createDescription = createDescription;
|
|
19
|
-
const addProperty = (inputsFile, inputName, propertyList) => {
|
|
20
|
-
const placeholder = inputsFile.addVariableStatement({
|
|
21
|
-
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
22
|
-
declarations: [
|
|
23
|
-
{ name: "genericActionInput", initializer: ts_morph_1.Writers.object({}) },
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
const object = placeholder.getDeclarations()[0].getInitializer();
|
|
27
|
-
object.addPropertyAssignments(propertyList);
|
|
28
|
-
inputsFile.addVariableStatement({
|
|
29
|
-
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
30
|
-
isExported: true,
|
|
31
|
-
declarations: [
|
|
32
|
-
{ name: inputName, initializer: `input(${object.print()})` },
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
placeholder.remove();
|
|
36
|
-
};
|
|
37
|
-
const addRequiredInputs = (projectType, inputsFile, addRetry) => {
|
|
38
|
-
addProperty(inputsFile, "apiBaseUrl", [
|
|
39
|
-
{ name: `"label"`, initializer: `"API Base URL"` },
|
|
40
|
-
{ name: `"type"`, initializer: `"string"` },
|
|
41
|
-
{ name: `"required"`, initializer: `false` },
|
|
42
|
-
{
|
|
43
|
-
name: `"comments"`,
|
|
44
|
-
initializer: `"An optional url you can specify to override the default provided by the OpenAPI spec."`,
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
addProperty(inputsFile, "debugRequest", [
|
|
48
|
-
{ name: `"label"`, initializer: `"Debug Request"` },
|
|
49
|
-
{ name: `"type"`, initializer: `"boolean"` },
|
|
50
|
-
{ name: `"required"`, initializer: `false` },
|
|
51
|
-
{
|
|
52
|
-
name: `"comments"`,
|
|
53
|
-
initializer: `"An optional boolean you can toggle to log the contents of the HTTP request for each action."`,
|
|
54
|
-
},
|
|
55
|
-
]);
|
|
56
|
-
addProperty(inputsFile, "timeout", [
|
|
57
|
-
{ name: `"label"`, initializer: `"Timeout"` },
|
|
58
|
-
{ name: `"type"`, initializer: `"string"` },
|
|
59
|
-
{ name: `"required"`, initializer: `false` },
|
|
60
|
-
{
|
|
61
|
-
name: `"comments"`,
|
|
62
|
-
initializer: `"An optional input that indicates how long the client will await a response."`,
|
|
63
|
-
},
|
|
64
|
-
]);
|
|
65
|
-
if (addRetry) {
|
|
66
|
-
addProperty(inputsFile, "maxRetries", [
|
|
67
|
-
{ name: `"label"`, initializer: `"Max Retries"` },
|
|
68
|
-
{ name: `"type"`, initializer: `"string"` },
|
|
69
|
-
{ name: `"required"`, initializer: `false` },
|
|
70
|
-
{
|
|
71
|
-
name: `"comments"`,
|
|
72
|
-
initializer: `"An optional input that indicates how many times this client will retry the request."`,
|
|
73
|
-
},
|
|
74
|
-
]);
|
|
75
|
-
addProperty(inputsFile, "retryDelayMS", [
|
|
76
|
-
{ name: `"label"`, initializer: `"Retry Delay (MS)"` },
|
|
77
|
-
{ name: `"type"`, initializer: `"string"` },
|
|
78
|
-
{ name: `"required"`, initializer: `false` },
|
|
79
|
-
{
|
|
80
|
-
name: `"comments"`,
|
|
81
|
-
initializer: `"An optional input that indicates a delay between retries."`,
|
|
82
|
-
},
|
|
83
|
-
]);
|
|
84
|
-
addProperty(inputsFile, "retryOnAllErrors", [
|
|
85
|
-
{ name: `"label"`, initializer: `"Retry On All Errors"` },
|
|
86
|
-
{ name: `"type"`, initializer: `"boolean"` },
|
|
87
|
-
{ name: `"required"`, initializer: `false` },
|
|
88
|
-
{
|
|
89
|
-
name: `"comments"`,
|
|
90
|
-
initializer: `"An optional boolean that will have the client retry the request, regardless of what type of error is thrown."`,
|
|
91
|
-
},
|
|
92
|
-
]);
|
|
93
|
-
addProperty(inputsFile, "useExponentialBackoff", [
|
|
94
|
-
{ name: `"label"`, initializer: `"Use Exponential Backoff"` },
|
|
95
|
-
{ name: `"type"`, initializer: `"boolean"` },
|
|
96
|
-
{ name: `"required"`, initializer: `false` },
|
|
97
|
-
{
|
|
98
|
-
name: `"comments"`,
|
|
99
|
-
initializer: `"An optional boolean that will enable exponential backoff on retry."`,
|
|
100
|
-
},
|
|
101
|
-
]);
|
|
102
|
-
}
|
|
103
|
-
return inputsFile;
|
|
104
|
-
};
|
|
105
|
-
exports.addRequiredInputs = addRequiredInputs;
|
|
106
|
-
const appendRequiredFields = ({ inputFields, addRetry, includeClient, }) => {
|
|
107
|
-
if (!includeClient) {
|
|
108
|
-
return inputFields;
|
|
109
|
-
}
|
|
110
|
-
const base = [...inputFields, "apiBaseUrl", "debugRequest", "timeout"];
|
|
111
|
-
return addRetry
|
|
112
|
-
? [
|
|
113
|
-
...base,
|
|
114
|
-
"maxRetries",
|
|
115
|
-
"retryDelayMS",
|
|
116
|
-
"retryOnAllErrors",
|
|
117
|
-
"useExponentialBackoff",
|
|
118
|
-
]
|
|
119
|
-
: base;
|
|
120
|
-
};
|
|
121
|
-
exports.appendRequiredFields = appendRequiredFields;
|