@fonoster/ctl 0.3.2 → 0.3.6-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -52
- package/dist/base/delete.js +7 -2
- package/dist/commands/agents/create.js +1 -1
- package/dist/commands/apps/create.d.ts +6 -0
- package/dist/commands/apps/create.js +186 -0
- package/dist/commands/apps/delete.d.ts +9 -0
- package/dist/commands/apps/delete.js +36 -0
- package/dist/commands/apps/list.d.ts +10 -0
- package/dist/commands/apps/list.js +90 -0
- package/dist/commands/apps/update.d.ts +9 -0
- package/dist/commands/apps/update.js +206 -0
- package/dist/commands/auth/login.js +1 -1
- package/dist/commands/domains/create.js +1 -1
- package/dist/commands/numbers/create.js +1 -1
- package/dist/commands/numbers/update.js +15 -4
- package/dist/commands/projects/create.js +1 -1
- package/dist/commands/providers/create.js +1 -1
- package/dist/commands/secrets/create.d.ts +14 -0
- package/dist/commands/secrets/create.js +64 -0
- package/dist/commands/secrets/delete.d.ts +10 -0
- package/dist/commands/secrets/delete.js +57 -0
- package/dist/commands/secrets/list.d.ts +10 -0
- package/dist/commands/secrets/list.js +71 -0
- package/dist/data/voices.d.ts +1 -0
- package/dist/data/voices.js +319 -0
- package/dist/decorators/project_guard.d.ts +9 -0
- package/dist/decorators/project_guard.js +26 -0
- package/dist/help.d.ts +3 -1
- package/dist/help.js +21 -16
- package/oclif.manifest.json +1 -1
- package/package.json +23 -42
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
require("../../config");
|
|
10
|
+
const errors_1 = require("@oclif/errors");
|
|
11
|
+
const command_1 = require("@oclif/command");
|
|
12
|
+
const cli_ux_1 = require("cli-ux");
|
|
13
|
+
const config_1 = require("../../config");
|
|
14
|
+
const project_guard_1 = require("../../decorators/project_guard");
|
|
15
|
+
const voices_1 = require("../../data/voices");
|
|
16
|
+
const Apps = require("@fonoster/apps");
|
|
17
|
+
const Secrets = require("@fonoster/secrets");
|
|
18
|
+
const inquirer = require("inquirer");
|
|
19
|
+
const validator = (value, message = "This field is required") => Boolean(value?.trim()?.length) || message;
|
|
20
|
+
class CreateCommand extends command_1.Command {
|
|
21
|
+
async run() {
|
|
22
|
+
console.log("This utility will help you create a new Fonoster App");
|
|
23
|
+
console.log("Press ^C at any time to quit.\n");
|
|
24
|
+
try {
|
|
25
|
+
const { secrets: response } = await new Secrets((0, config_1.getProjectConfig)()).listSecrets({
|
|
26
|
+
pageSize: 25,
|
|
27
|
+
pageToken: "1"
|
|
28
|
+
});
|
|
29
|
+
const secrets = response.map(({ name }) => name) || [];
|
|
30
|
+
if (secrets.length === 0) {
|
|
31
|
+
throw new errors_1.CLIError("Before adding a App you must create a Secret");
|
|
32
|
+
}
|
|
33
|
+
const answers = await inquirer.prompt([
|
|
34
|
+
{
|
|
35
|
+
name: "name",
|
|
36
|
+
message: "Application Name",
|
|
37
|
+
type: "input",
|
|
38
|
+
validate: (value) => validator(value, "You must enter a name for your Application, try something friendly.")
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "speechConfig.voice",
|
|
42
|
+
message: "Voice name",
|
|
43
|
+
type: "list",
|
|
44
|
+
choices: voices_1.voices,
|
|
45
|
+
validate: (value) => validator(value, "You must select a voice")
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "speechConfig.secretName",
|
|
49
|
+
message: "Speech Config Secret",
|
|
50
|
+
type: "list",
|
|
51
|
+
choices: secrets,
|
|
52
|
+
validate: (value) => validator(value, "You must select a secret")
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "intentsEngineConfig.welcomeIntentId",
|
|
56
|
+
message: "Type the welcome intent ID (e.g. WELCOME)",
|
|
57
|
+
type: "input"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "engine",
|
|
61
|
+
message: "Select Intents Engine Type",
|
|
62
|
+
type: "list",
|
|
63
|
+
choices: ["DialogflowES"],
|
|
64
|
+
validate: (value) => validator(value, "You must select a engine")
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "intentsEngineConfig.projectId",
|
|
68
|
+
message: "Type a project ID",
|
|
69
|
+
type: "input",
|
|
70
|
+
validate: (value) => validator(value, "You must enter a project ID for your Application.")
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "intentsEngineConfig.secretName",
|
|
74
|
+
message: "Intents Engine Secret",
|
|
75
|
+
type: "list",
|
|
76
|
+
choices: secrets,
|
|
77
|
+
validate: (value) => validator(value, "You must select a secret")
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "intentsEngineConfig.agent",
|
|
81
|
+
message: "Type a agent",
|
|
82
|
+
type: "input",
|
|
83
|
+
when: (answers) => answers.engine === "DialogflowES",
|
|
84
|
+
validate: (value) => validator(value, "You must enter a agent for your Application.")
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "intentsEngineConfig.location",
|
|
88
|
+
message: "Type a location",
|
|
89
|
+
type: "input",
|
|
90
|
+
when: (answers) => answers.engine === "DialogflowES",
|
|
91
|
+
validate: (value) => validator(value, "You must enter a location for your Application.")
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "showAdvanceOptions",
|
|
95
|
+
message: "Show advance options?",
|
|
96
|
+
type: "confirm"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "initialDtmf",
|
|
100
|
+
message: "Initial DTMF (optional)",
|
|
101
|
+
type: "input",
|
|
102
|
+
when: (answers) => answers.showAdvanceOptions,
|
|
103
|
+
validate: (value) => {
|
|
104
|
+
const regex = /^[0-9*#]*$/;
|
|
105
|
+
if (value && !regex.test(value)) {
|
|
106
|
+
return "You must enter a valid DTMF. It’s a string that allows 1234567890#*";
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "activationIntentId",
|
|
113
|
+
message: "Type the activation intent ID (optional)",
|
|
114
|
+
type: "input",
|
|
115
|
+
when: (answers) => answers.showAdvanceOptions
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "activationTimeout",
|
|
119
|
+
message: "Type the activation timeout (e.g. 15000)",
|
|
120
|
+
type: "input",
|
|
121
|
+
when: (answers) => answers.showAdvanceOptions,
|
|
122
|
+
validate: (value) => {
|
|
123
|
+
const regex = /^[0-9]*$/;
|
|
124
|
+
if (value && !regex.test(value)) {
|
|
125
|
+
return "You must enter a valid timeout. It’s a number in milliseconds";
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "interactionTimeout",
|
|
132
|
+
message: "Type the interaction timeout (e.g. 10000)",
|
|
133
|
+
type: "input",
|
|
134
|
+
when: (answers) => answers.showAdvanceOptions,
|
|
135
|
+
validate: (value) => {
|
|
136
|
+
const regex = /^[0-9]*$/;
|
|
137
|
+
if (value && !regex.test(value)) {
|
|
138
|
+
return "You must enter a valid timeout. It’s a number in milliseconds";
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "transferConfig.message",
|
|
145
|
+
message: "Type a transfer message (e.g. Please wait while we transfer you)",
|
|
146
|
+
type: "input",
|
|
147
|
+
when: (answers) => answers.showAdvanceOptions
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "intentsEngineConfig.emulateTelephonyPlatform",
|
|
151
|
+
message: "Emulate Telephony Platform",
|
|
152
|
+
type: "confirm",
|
|
153
|
+
when: (answers) => answers.showAdvanceOptions
|
|
154
|
+
}
|
|
155
|
+
]);
|
|
156
|
+
const confirmPrompt = await inquirer.prompt([
|
|
157
|
+
{
|
|
158
|
+
name: "confirm",
|
|
159
|
+
message: "Ready to create your App?",
|
|
160
|
+
type: "confirm"
|
|
161
|
+
}
|
|
162
|
+
]);
|
|
163
|
+
if (!confirmPrompt.confirm)
|
|
164
|
+
return console.log("Aborted");
|
|
165
|
+
cli_ux_1.cli.action.start(`Creating App ${answers.name}`);
|
|
166
|
+
const apps = new Apps((0, config_1.getProjectConfig)());
|
|
167
|
+
delete answers.showAdvanceOptions;
|
|
168
|
+
delete answers.engine;
|
|
169
|
+
const result = await apps.createApp(answers);
|
|
170
|
+
await cli_ux_1.cli.wait(1000);
|
|
171
|
+
cli_ux_1.cli.action.stop(result.ref);
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
cli_ux_1.cli.action.stop();
|
|
175
|
+
throw new errors_1.CLIError(e.code === 9 ? "This App already exist" : e.message);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
CreateCommand.description = `create a new Fonoster App
|
|
180
|
+
...
|
|
181
|
+
Create a new Fonoster App
|
|
182
|
+
`;
|
|
183
|
+
__decorate([
|
|
184
|
+
(0, project_guard_1.ProjectGuard)()
|
|
185
|
+
], CreateCommand.prototype, "run", null);
|
|
186
|
+
exports.default = CreateCommand;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const delete_1 = __importDefault(require("../../base/delete"));
|
|
13
|
+
const errors_1 = require("@oclif/errors");
|
|
14
|
+
const config_1 = require("../../config");
|
|
15
|
+
const project_guard_1 = require("../../decorators/project_guard");
|
|
16
|
+
const Apps = require("@fonoster/apps");
|
|
17
|
+
class DeleteCommand extends delete_1.default {
|
|
18
|
+
async run() {
|
|
19
|
+
try {
|
|
20
|
+
await super.deleteResource(new Apps((0, config_1.getProjectConfig)()), "deleteApp");
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
const message = e.code === 9
|
|
24
|
+
? "unable to delete: please ensure no Resource is using this Fonoster Application"
|
|
25
|
+
: e.message;
|
|
26
|
+
throw new errors_1.CLIError(message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
DeleteCommand.description = "delete a Fonoster Application";
|
|
31
|
+
DeleteCommand.args = [{ name: "ref" }];
|
|
32
|
+
DeleteCommand.aliases = ["apps:del", "apps:rm"];
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, project_guard_1.ProjectGuard)()
|
|
35
|
+
], DeleteCommand.prototype, "run", null);
|
|
36
|
+
exports.default = DeleteCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "../../config";
|
|
2
|
+
import { Command } from "@oclif/command";
|
|
3
|
+
export default class ListCommand extends Command {
|
|
4
|
+
static description: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
size: import("@oclif/parser/lib/flags").IOptionFlag<number>;
|
|
7
|
+
};
|
|
8
|
+
static aliases: string[];
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
require("../../config");
|
|
10
|
+
const domains_1 = require("@fonoster/domains");
|
|
11
|
+
const errors_1 = require("@oclif/errors");
|
|
12
|
+
const command_1 = require("@oclif/command");
|
|
13
|
+
const cli_ux_1 = require("cli-ux");
|
|
14
|
+
const config_1 = require("../../config");
|
|
15
|
+
const project_guard_1 = require("../../decorators/project_guard");
|
|
16
|
+
const Apps = require("@fonoster/apps");
|
|
17
|
+
const inquirer = require("inquirer");
|
|
18
|
+
class ListCommand extends command_1.Command {
|
|
19
|
+
async run() {
|
|
20
|
+
const { flags } = this.parse(ListCommand);
|
|
21
|
+
try {
|
|
22
|
+
const apps = new Apps((0, config_1.getProjectConfig)());
|
|
23
|
+
let firstBatch = true;
|
|
24
|
+
let pageToken = "1";
|
|
25
|
+
const pageSize = flags.size;
|
|
26
|
+
const view = domains_1.CommonPB.View.BASIC;
|
|
27
|
+
// while (true) {
|
|
28
|
+
// Get a list
|
|
29
|
+
const result = await apps.listApps({ pageSize, pageToken, view });
|
|
30
|
+
const list = result.apps;
|
|
31
|
+
pageToken = result.nextPageToken;
|
|
32
|
+
/**
|
|
33
|
+
* @todo Uncomment when pagination is applied in backend.
|
|
34
|
+
*
|
|
35
|
+
* if (list.length > 0 && !firstBatch) {
|
|
36
|
+
const answer: any = await inquirer.prompt([
|
|
37
|
+
{name: "q", message: "More", type: "confirm"}
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
if (!answer.q) break;
|
|
41
|
+
}
|
|
42
|
+
*/
|
|
43
|
+
// if (list.length < 1) break;
|
|
44
|
+
const showTable = (showHeader, data) => {
|
|
45
|
+
cli_ux_1.cli.table(data, {
|
|
46
|
+
ref: { minWidth: 15 },
|
|
47
|
+
name: { header: "Name", minWidth: 15 },
|
|
48
|
+
projectId: {
|
|
49
|
+
header: "Project ID",
|
|
50
|
+
minWidth: 15,
|
|
51
|
+
get: (row) => row.intentsEngineConfig?.projectId || "N/A"
|
|
52
|
+
},
|
|
53
|
+
voice: {
|
|
54
|
+
header: "Voice",
|
|
55
|
+
minWidth: 20,
|
|
56
|
+
get: (row) => row.speechConfig?.voice || "N/A"
|
|
57
|
+
},
|
|
58
|
+
welcomeIntentId: {
|
|
59
|
+
header: "Welcome Intent ID",
|
|
60
|
+
minWidth: 15,
|
|
61
|
+
get: (row) => row.intentsEngineConfig?.welcomeIntentId || "N/A"
|
|
62
|
+
}
|
|
63
|
+
}, { "no-header": !showHeader });
|
|
64
|
+
};
|
|
65
|
+
showTable(firstBatch, list);
|
|
66
|
+
firstBatch = false;
|
|
67
|
+
// if (!pageToken) break;
|
|
68
|
+
// }
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
throw new errors_1.CLIError(e.message);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
ListCommand.description = `list all Fonoster Apps you have access to
|
|
76
|
+
...
|
|
77
|
+
List all Fonoster Apps you have access to
|
|
78
|
+
`;
|
|
79
|
+
ListCommand.flags = {
|
|
80
|
+
size: command_1.flags.integer({
|
|
81
|
+
char: "s",
|
|
82
|
+
default: 25,
|
|
83
|
+
description: "number of result per page"
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
ListCommand.aliases = ["apps:ls"];
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, project_guard_1.ProjectGuard)()
|
|
89
|
+
], ListCommand.prototype, "run", null);
|
|
90
|
+
exports.default = ListCommand;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
require("../../config");
|
|
10
|
+
const errors_1 = require("@oclif/errors");
|
|
11
|
+
const command_1 = require("@oclif/command");
|
|
12
|
+
const cli_ux_1 = require("cli-ux");
|
|
13
|
+
const config_1 = require("../../config");
|
|
14
|
+
const project_guard_1 = require("../../decorators/project_guard");
|
|
15
|
+
const voices_1 = require("../../data/voices");
|
|
16
|
+
const Apps = require("@fonoster/apps");
|
|
17
|
+
const Secrets = require("@fonoster/secrets");
|
|
18
|
+
const inquirer = require("inquirer");
|
|
19
|
+
const validator = (value, message = "This field is required") => Boolean(value?.trim()?.length) || message;
|
|
20
|
+
class UpdateCommand extends command_1.Command {
|
|
21
|
+
async run() {
|
|
22
|
+
try {
|
|
23
|
+
const { args } = this.parse(UpdateCommand);
|
|
24
|
+
if (!args.ref)
|
|
25
|
+
throw new errors_1.CLIError("Please provide the reference of your Fonoster Application");
|
|
26
|
+
const { secrets: response } = await new Secrets((0, config_1.getProjectConfig)())
|
|
27
|
+
.listSecrets({
|
|
28
|
+
pageSize: 25,
|
|
29
|
+
pageToken: "1"
|
|
30
|
+
});
|
|
31
|
+
const secrets = response.map(({ name }) => name) || [];
|
|
32
|
+
const appsManager = new Apps((0, config_1.getProjectConfig)());
|
|
33
|
+
const app = await appsManager.getApp(args.ref);
|
|
34
|
+
if (!app)
|
|
35
|
+
throw new errors_1.CLIError("App not found");
|
|
36
|
+
const answers = await inquirer.prompt([
|
|
37
|
+
{
|
|
38
|
+
name: "name",
|
|
39
|
+
message: "Application Name",
|
|
40
|
+
type: "input",
|
|
41
|
+
default: app.name,
|
|
42
|
+
validate: (value) => validator(value, "You must enter a name for your Application, try something friendly.")
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "speechConfig.voice",
|
|
46
|
+
message: "Voice name",
|
|
47
|
+
type: "list",
|
|
48
|
+
default: app.speechConfig.voice,
|
|
49
|
+
choices: voices_1.voices,
|
|
50
|
+
validate: (value) => validator(value, "You must select a voice")
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "speechConfig.secretName",
|
|
54
|
+
message: "Speech Config Secret",
|
|
55
|
+
type: "list",
|
|
56
|
+
choices: secrets,
|
|
57
|
+
default: app.speechConfig.secretName,
|
|
58
|
+
validate: (value) => validator(value, "You must select a secret")
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "intentsEngineConfig.welcomeIntentId",
|
|
62
|
+
message: "Type the welcome intent ID (e.g. WELCOME)",
|
|
63
|
+
type: "input",
|
|
64
|
+
default: app.intentsEngineConfig.welcomeIntentId,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "engine",
|
|
68
|
+
message: "Select Intents Engine Type",
|
|
69
|
+
type: "list",
|
|
70
|
+
choices: ["DialogflowES"],
|
|
71
|
+
validate: (value) => validator(value, "You must select a engine")
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "intentsEngineConfig.projectId",
|
|
75
|
+
message: "Type a project ID",
|
|
76
|
+
type: "input",
|
|
77
|
+
default: app.intentsEngineConfig.projectId,
|
|
78
|
+
validate: (value) => validator(value, "You must enter a project ID for your Application.")
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "intentsEngineConfig.secretName",
|
|
82
|
+
message: "Intents Engine Secret",
|
|
83
|
+
type: "list",
|
|
84
|
+
choices: secrets,
|
|
85
|
+
default: app.intentsEngineConfig.secretName,
|
|
86
|
+
validate: (value) => validator(value, "You must select a secret")
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "intentsEngineConfig.agent",
|
|
90
|
+
message: "Type a agent",
|
|
91
|
+
type: "input",
|
|
92
|
+
default: app.intentsEngineConfig.agent,
|
|
93
|
+
when: (answers) => answers.engine === "DialogflowES",
|
|
94
|
+
validate: (value) => validator(value, "You must enter a agent for your Application.")
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "intentsEngineConfig.location",
|
|
98
|
+
message: "Type a location",
|
|
99
|
+
type: "input",
|
|
100
|
+
default: app.intentsEngineConfig.location,
|
|
101
|
+
when: (answers) => answers.engine === "DialogflowES",
|
|
102
|
+
validate: (value) => validator(value, "You must enter a location for your Application.")
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "showAdvanceOptions",
|
|
106
|
+
message: "Show advance options?",
|
|
107
|
+
type: "confirm",
|
|
108
|
+
default: true
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "initialDtmf",
|
|
112
|
+
message: "Initial DTMF (optional)",
|
|
113
|
+
type: "input",
|
|
114
|
+
default: app.initialDtmf,
|
|
115
|
+
when: (answers) => answers.showAdvanceOptions,
|
|
116
|
+
validate: (value) => {
|
|
117
|
+
const regex = /^[0-9*#]*$/;
|
|
118
|
+
if (value && !regex.test(value)) {
|
|
119
|
+
return "You must enter a valid DTMF. It’s a string that allows 1234567890#*";
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "activationIntentId",
|
|
126
|
+
message: "Type the activation intent ID (optional)",
|
|
127
|
+
type: "input",
|
|
128
|
+
default: app.activationIntentId,
|
|
129
|
+
when: (answers) => answers.showAdvanceOptions
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "activationTimeout",
|
|
133
|
+
message: "Type the activation timeout (e.g. 15000)",
|
|
134
|
+
type: "input",
|
|
135
|
+
default: app.activationTimeout,
|
|
136
|
+
when: (answers) => answers.showAdvanceOptions,
|
|
137
|
+
validate: (value) => {
|
|
138
|
+
const regex = /^[0-9]*$/;
|
|
139
|
+
if (value && !regex.test(value)) {
|
|
140
|
+
return "You must enter a valid timeout. It’s a number in milliseconds";
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "interactionTimeout",
|
|
147
|
+
message: "Type the interaction timeout (e.g. 10000)",
|
|
148
|
+
type: "input",
|
|
149
|
+
default: app.interactionTimeout,
|
|
150
|
+
when: (answers) => answers.showAdvanceOptions,
|
|
151
|
+
validate: (value) => {
|
|
152
|
+
const regex = /^[0-9]*$/;
|
|
153
|
+
if (value && !regex.test(value)) {
|
|
154
|
+
return "You must enter a valid timeout. It’s a number in milliseconds";
|
|
155
|
+
}
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "transferConfig.message",
|
|
161
|
+
message: "Type a transfer message (e.g. Please wait while we transfer you)",
|
|
162
|
+
type: "input",
|
|
163
|
+
default: app.transferConfig.message,
|
|
164
|
+
when: (answers) => answers.showAdvanceOptions
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "intentsEngineConfig.emulateTelephonyPlatform",
|
|
168
|
+
message: "Emulate Telephony Platform",
|
|
169
|
+
type: "confirm",
|
|
170
|
+
default: app.intentsEngineConfig.emulateTelephonyPlatform,
|
|
171
|
+
when: (answers) => answers.showAdvanceOptions
|
|
172
|
+
}
|
|
173
|
+
]);
|
|
174
|
+
const confirmPrompt = await inquirer.prompt([
|
|
175
|
+
{
|
|
176
|
+
name: "confirm",
|
|
177
|
+
message: "Ready to update your App?",
|
|
178
|
+
type: "confirm"
|
|
179
|
+
}
|
|
180
|
+
]);
|
|
181
|
+
if (!confirmPrompt.confirm)
|
|
182
|
+
return console.log("Aborted");
|
|
183
|
+
cli_ux_1.cli.action.start(`Updating App ${answers.name}`);
|
|
184
|
+
const apps = new Apps((0, config_1.getProjectConfig)());
|
|
185
|
+
delete answers.showAdvanceOptions;
|
|
186
|
+
delete answers.engine;
|
|
187
|
+
answers.ref = args.ref;
|
|
188
|
+
const result = await apps.updateApp(answers);
|
|
189
|
+
await cli_ux_1.cli.wait(1000);
|
|
190
|
+
cli_ux_1.cli.action.stop(`App ${result.ref} updated`);
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
cli_ux_1.cli.action.stop();
|
|
194
|
+
throw new errors_1.CLIError(e.code === 9 ? "This App already exist" : e.message);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
UpdateCommand.args = [{ name: "ref" }];
|
|
199
|
+
UpdateCommand.description = `update a new Fonoster App
|
|
200
|
+
...
|
|
201
|
+
Update a new Fonoster App
|
|
202
|
+
`;
|
|
203
|
+
__decorate([
|
|
204
|
+
(0, project_guard_1.ProjectGuard)()
|
|
205
|
+
], UpdateCommand.prototype, "run", null);
|
|
206
|
+
exports.default = UpdateCommand;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.UpdateCommand = void 0;
|
|
4
10
|
require("../../config");
|
|
@@ -6,16 +12,18 @@ const errors_1 = require("@oclif/errors");
|
|
|
6
12
|
const command_1 = require("@oclif/command");
|
|
7
13
|
const cli_ux_1 = require("cli-ux");
|
|
8
14
|
const config_1 = require("../../config");
|
|
15
|
+
const project_guard_1 = require("../../decorators/project_guard");
|
|
9
16
|
const Numbers = require("@fonoster/numbers");
|
|
10
17
|
const inquirer = require("inquirer");
|
|
11
18
|
class UpdateCommand extends command_1.Command {
|
|
12
19
|
async run() {
|
|
13
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
14
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
15
|
-
}
|
|
16
20
|
console.log("This utility will help you update an existing Fonoster Number");
|
|
17
21
|
console.log("Press ^C at any time to quit.");
|
|
18
22
|
const { args } = this.parse(UpdateCommand);
|
|
23
|
+
if (!args.ref) {
|
|
24
|
+
cli_ux_1.cli.action.stop();
|
|
25
|
+
throw new errors_1.CLIError("You must provide a Number ref before continuing");
|
|
26
|
+
}
|
|
19
27
|
const numbers = new Numbers((0, config_1.getProjectConfig)());
|
|
20
28
|
const answers = await inquirer.prompt([
|
|
21
29
|
{
|
|
@@ -67,9 +75,12 @@ class UpdateCommand extends command_1.Command {
|
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
|
-
exports.UpdateCommand = UpdateCommand;
|
|
71
78
|
UpdateCommand.description = `update a Fonoster Number
|
|
72
79
|
...
|
|
73
80
|
Update a Fonoster Number
|
|
74
81
|
`;
|
|
75
82
|
UpdateCommand.args = [{ name: "ref" }];
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, project_guard_1.ProjectGuard)()
|
|
85
|
+
], UpdateCommand.prototype, "run", null);
|
|
86
|
+
exports.UpdateCommand = UpdateCommand;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../../config";
|
|
2
|
+
import { Command, flags } from "@oclif/command";
|
|
3
|
+
export default class CreateCommand extends Command {
|
|
4
|
+
static description: string;
|
|
5
|
+
static args: {
|
|
6
|
+
name: string;
|
|
7
|
+
}[];
|
|
8
|
+
static flags: {
|
|
9
|
+
help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
|
|
10
|
+
"from-literal": flags.IOptionFlag<string>;
|
|
11
|
+
"from-stdin": import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|