liveperson-functions-cli
Version:
LivePerson Functions CLI
104 lines • 3.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateView = void 0;
const printer_1 = require("./printer");
const utils_1 = require("../shared/utils");
class CreateView {
constructor({ log = new printer_1.LogMessage(), error = new printer_1.ErrorMessage(), chalk = printer_1.chalk, prompt = new printer_1.Prompt(), } = {}) {
this.log = log;
this.error = error;
this.chalk = chalk;
this.prompt = prompt;
}
/**
* Show when a function has been created
* @memberof CreateView
* @param functionParameters
*/
showFunctionIsCreated(functionParameters) {
this.log.print(`The function "${this.chalk.green(functionParameters.name)}" has been created`);
}
/**
* Show when a function has been created
* @memberof CreateView
* @param schedule
*/
showScheduleIsCreated(nextExecution) {
this.log.print(`The schedule has been created. Next execution: ${this.chalk.blue(nextExecution)}`);
}
/**
* Shows an error message
* @param {string|PrettyPrintableError} message - message
* @memberof CreateView
*/
showErrorMessage(message) {
this.error.print(message);
}
/**
* Shows a message
* @param {string} message - message
* @memberof CreateView
*/
showMessage(message) {
this.log.print(message);
}
async askForFunctionName() {
/* istanbul ignore next */
this.prompt.addQuestion({
name: 'name',
type: 'Input',
validate: async (value) => (0, utils_1.validateFunctionName)(value),
message: 'Name',
});
return this.prompt.run();
}
async askForFunctionDescription() {
/* istanbul ignore next */
this.prompt.addQuestion({
name: 'description',
type: 'Input',
validate: async (value) => (0, utils_1.validateFunctionDescription)(value),
message: 'Description',
});
return this.prompt.run();
}
async askForEventID(eventIDs) {
if (eventIDs) {
this.prompt.addQuestion({
name: 'eventId',
type: 'list',
message: 'Choose an eventId',
choices: eventIDs,
});
}
else {
this.prompt.addQuestion({
name: 'eventId',
type: 'Input',
default: 'No Event',
message: 'Event ID',
});
}
return this.prompt.run();
}
async askForDeployedLambda(lambdaNames) {
this.prompt.addQuestion({
name: 'name',
type: 'list',
message: 'Choose a deployed lambda',
choices: lambdaNames,
});
return this.prompt.run();
}
async askForCronExpression() {
this.prompt.addQuestion({
name: 'cronExpression',
type: 'Input',
default: '* * * * *',
message: 'Cron Expression',
});
return this.prompt.run();
}
}
exports.CreateView = CreateView;
//# sourceMappingURL=create.view.js.map