@fonoster/ctl 0.4.7 → 0.7.37
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/LICENSE +2 -2
- package/README.md +349 -606
- package/bin/run.js +7 -0
- package/dist/commands/workspace/login.d.ts +6 -0
- package/dist/commands/workspace/login.js +80 -0
- package/dist/config/addWorkspace.d.ts +3 -0
- package/dist/config/addWorkspace.js +10 -0
- package/dist/config/getConfig.d.ts +3 -0
- package/dist/{commands/projects/delete.js → config/getConfig.js} +10 -14
- package/dist/config/getCurrentWorkspace.d.ts +3 -0
- package/dist/config/getCurrentWorkspace.js +10 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.js +41 -0
- package/dist/config/removeWorkspace.d.ts +3 -0
- package/dist/config/removeWorkspace.js +6 -0
- package/dist/config/saveConfig.d.ts +3 -0
- package/dist/{commands/feedback.js → config/saveConfig.js} +11 -12
- package/dist/config/setCurrentWorkspace.d.ts +3 -0
- package/dist/config/setCurrentWorkspace.js +11 -0
- package/dist/config/types.d.ts +4 -0
- package/dist/config/types.js +2 -0
- package/dist/config/validations.d.ts +24 -0
- package/dist/{index.js → config/validations.js} +12 -4
- package/dist/constants.d.ts +3 -0
- package/dist/{utils.js → constants.js} +7 -10
- package/package.json +29 -64
- package/bin/run +0 -5
- package/bin/run.cmd +0 -3
- package/dist/base/delete.d.ts +0 -9
- package/dist/base/delete.js +0 -50
- package/dist/commands/agents/create.d.ts +0 -6
- package/dist/commands/agents/create.js +0 -112
- package/dist/commands/agents/delete.d.ts +0 -9
- package/dist/commands/agents/delete.js +0 -39
- package/dist/commands/agents/get.d.ts +0 -9
- package/dist/commands/agents/get.js +0 -60
- package/dist/commands/agents/list.d.ts +0 -10
- package/dist/commands/agents/list.js +0 -92
- package/dist/commands/agents/update.d.ts +0 -9
- package/dist/commands/agents/update.js +0 -90
- package/dist/commands/apps/create.d.ts +0 -6
- package/dist/commands/apps/create.js +0 -213
- package/dist/commands/apps/delete.d.ts +0 -9
- package/dist/commands/apps/delete.js +0 -54
- package/dist/commands/apps/list.d.ts +0 -10
- package/dist/commands/apps/list.js +0 -107
- package/dist/commands/apps/update.d.ts +0 -9
- package/dist/commands/apps/update.js +0 -235
- package/dist/commands/auth/login.d.ts +0 -6
- package/dist/commands/auth/login.js +0 -84
- package/dist/commands/auth/logout.d.ts +0 -6
- package/dist/commands/auth/logout.js +0 -46
- package/dist/commands/bug.d.ts +0 -6
- package/dist/commands/bug.js +0 -33
- package/dist/commands/domains/create.d.ts +0 -6
- package/dist/commands/domains/create.js +0 -130
- package/dist/commands/domains/delete.d.ts +0 -9
- package/dist/commands/domains/delete.js +0 -49
- package/dist/commands/domains/get.d.ts +0 -9
- package/dist/commands/domains/get.js +0 -63
- package/dist/commands/domains/list.d.ts +0 -10
- package/dist/commands/domains/list.js +0 -95
- package/dist/commands/domains/update.d.ts +0 -9
- package/dist/commands/domains/update.js +0 -124
- package/dist/commands/feedback.d.ts +0 -6
- package/dist/commands/numbers/create.d.ts +0 -6
- package/dist/commands/numbers/create.js +0 -117
- package/dist/commands/numbers/delete.d.ts +0 -9
- package/dist/commands/numbers/delete.js +0 -49
- package/dist/commands/numbers/get.d.ts +0 -9
- package/dist/commands/numbers/get.js +0 -59
- package/dist/commands/numbers/list.d.ts +0 -10
- package/dist/commands/numbers/list.js +0 -100
- package/dist/commands/numbers/update.d.ts +0 -9
- package/dist/commands/numbers/update.js +0 -104
- package/dist/commands/projects/create.d.ts +0 -6
- package/dist/commands/projects/create.js +0 -75
- package/dist/commands/projects/delete.d.ts +0 -9
- package/dist/commands/projects/get.d.ts +0 -9
- package/dist/commands/projects/get.js +0 -55
- package/dist/commands/projects/list.d.ts +0 -6
- package/dist/commands/projects/list.js +0 -50
- package/dist/commands/projects/renew.d.ts +0 -9
- package/dist/commands/projects/renew.js +0 -47
- package/dist/commands/projects/use.d.ts +0 -9
- package/dist/commands/projects/use.js +0 -60
- package/dist/commands/providers/create.d.ts +0 -6
- package/dist/commands/providers/create.js +0 -114
- package/dist/commands/providers/delete.d.ts +0 -9
- package/dist/commands/providers/delete.js +0 -49
- package/dist/commands/providers/get.d.ts +0 -9
- package/dist/commands/providers/get.js +0 -61
- package/dist/commands/providers/list.d.ts +0 -10
- package/dist/commands/providers/list.js +0 -98
- package/dist/commands/providers/update.d.ts +0 -9
- package/dist/commands/providers/update.js +0 -113
- package/dist/commands/secrets/create.d.ts +0 -14
- package/dist/commands/secrets/create.js +0 -69
- package/dist/commands/secrets/delete.d.ts +0 -10
- package/dist/commands/secrets/delete.js +0 -57
- package/dist/commands/secrets/list.d.ts +0 -10
- package/dist/commands/secrets/list.js +0 -71
- package/dist/config.d.ts +0 -29
- package/dist/config.js +0 -73
- package/dist/data/voices.d.ts +0 -1
- package/dist/data/voices.js +0 -337
- package/dist/decorators/project_guard.d.ts +0 -9
- package/dist/decorators/project_guard.js +0 -44
- package/dist/help.d.ts +0 -6
- package/dist/help.js +0 -47
- package/dist/index.d.ts +0 -1
- package/dist/utils.d.ts +0 -1
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
5
|
-
* http://github.com/fonoster/fonoster
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Fonoster
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License (the "License");
|
|
10
|
-
* you may not use this file except in compliance with
|
|
11
|
-
* the License. You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* https://opensource.org/licenses/MIT
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
require("../../config");
|
|
22
|
-
const errors_1 = require("@oclif/errors");
|
|
23
|
-
const command_1 = require("@oclif/command");
|
|
24
|
-
const core_1 = require("@oclif/core");
|
|
25
|
-
const config_1 = require("../../config");
|
|
26
|
-
const utils_1 = require("../../utils");
|
|
27
|
-
const agents_1 = require("@fonoster/agents");
|
|
28
|
-
const Agents = require("@fonoster/agents");
|
|
29
|
-
const Domains = require("@fonoster/domains");
|
|
30
|
-
const inquirer = require("inquirer");
|
|
31
|
-
class default_1 extends command_1.Command {
|
|
32
|
-
async run() {
|
|
33
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
34
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
35
|
-
}
|
|
36
|
-
console.log("This utility will help you create a new Agent");
|
|
37
|
-
console.log("Press ^C at any time to quit.");
|
|
38
|
-
// TODO: Consider using the autocomplete plugin
|
|
39
|
-
const response = await new Domains((0, config_1.getProjectConfig)()).listDomains({
|
|
40
|
-
pageSize: 25,
|
|
41
|
-
pageToken: "1"
|
|
42
|
-
});
|
|
43
|
-
const domains = response.domains.map((app) => app.domainUri);
|
|
44
|
-
if (domains.length === 0) {
|
|
45
|
-
throw new Error("you must create a domain before adding an agent");
|
|
46
|
-
}
|
|
47
|
-
const answers = await inquirer.prompt([
|
|
48
|
-
{
|
|
49
|
-
name: "domain",
|
|
50
|
-
message: "domain",
|
|
51
|
-
type: "list",
|
|
52
|
-
choices: domains
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: "name",
|
|
56
|
-
message: "friendly name",
|
|
57
|
-
type: "input"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "username",
|
|
61
|
-
message: "username",
|
|
62
|
-
type: "input"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: "secret",
|
|
66
|
-
message: "secret",
|
|
67
|
-
type: "password",
|
|
68
|
-
mask: true
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: "privacy",
|
|
72
|
-
message: "privacy",
|
|
73
|
-
type: "list",
|
|
74
|
-
choices: [(0, utils_1.toPascalCase)(agents_1.Privacy.NONE), (0, utils_1.toPascalCase)(agents_1.Privacy.PRIVATE)],
|
|
75
|
-
default: "None"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "confirm",
|
|
79
|
-
message: "ready?",
|
|
80
|
-
type: "confirm"
|
|
81
|
-
}
|
|
82
|
-
]);
|
|
83
|
-
answers.domains = [answers.domain];
|
|
84
|
-
if (!answers.confirm) {
|
|
85
|
-
console.log("Aborted");
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
try {
|
|
89
|
-
core_1.CliUx.ux.action.start(`Creating agent ${answers.name}`);
|
|
90
|
-
const agents = new Agents((0, config_1.getProjectConfig)());
|
|
91
|
-
answers.privacy = agents_1.Privacy[answers.privacy.toUpperCase()];
|
|
92
|
-
const agent = await agents.createAgent(answers);
|
|
93
|
-
await core_1.CliUx.ux.wait(1000);
|
|
94
|
-
core_1.CliUx.ux.action.stop(agent.ref);
|
|
95
|
-
}
|
|
96
|
-
catch (e) {
|
|
97
|
-
core_1.CliUx.ux.action.stop();
|
|
98
|
-
if (e.code === 9) {
|
|
99
|
-
throw new errors_1.CLIError("This Agent already exist");
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
throw new errors_1.CLIError(e.message);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
default_1.description = `create a new Fonoster Agent
|
|
109
|
-
...
|
|
110
|
-
Create a new Fonoster Agent
|
|
111
|
-
`;
|
|
112
|
-
exports.default = default_1;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/*
|
|
7
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
8
|
-
* http://github.com/fonoster/fonoster
|
|
9
|
-
*
|
|
10
|
-
* This file is part of Fonoster
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the MIT License (the "License");
|
|
13
|
-
* you may not use this file except in compliance with
|
|
14
|
-
* the License. You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* https://opensource.org/licenses/MIT
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
const delete_1 = __importDefault(require("../../base/delete"));
|
|
25
|
-
const config_1 = require("../../config");
|
|
26
|
-
const errors_1 = require("@oclif/errors");
|
|
27
|
-
const Agents = require("@fonoster/agents");
|
|
28
|
-
class default_1 extends delete_1.default {
|
|
29
|
-
async run() {
|
|
30
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
31
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
32
|
-
}
|
|
33
|
-
await super.deleteResource(new Agents((0, config_1.getProjectConfig)()), "deleteAgent");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
default_1.description = "delete a Fonoster Agent";
|
|
37
|
-
default_1.args = [{ name: "ref" }];
|
|
38
|
-
default_1.aliases = ["agents:del", "agents:rm"];
|
|
39
|
-
exports.default = default_1;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
5
|
-
* http://github.com/fonoster/fonoster
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Fonoster
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License (the "License");
|
|
10
|
-
* you may not use this file except in compliance with
|
|
11
|
-
* the License. You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* https://opensource.org/licenses/MIT
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
require("../../config");
|
|
22
|
-
const errors_1 = require("@oclif/errors");
|
|
23
|
-
const command_1 = require("@oclif/command");
|
|
24
|
-
const core_1 = require("@oclif/core");
|
|
25
|
-
const prettyjson_1 = require("prettyjson");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const utils_1 = require("../../utils");
|
|
28
|
-
const Agents = require("@fonoster/agents");
|
|
29
|
-
const moment = require("moment");
|
|
30
|
-
class GetCommand extends command_1.Command {
|
|
31
|
-
async run() {
|
|
32
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
33
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
34
|
-
}
|
|
35
|
-
const { args } = this.parse(GetCommand);
|
|
36
|
-
try {
|
|
37
|
-
const agents = new Agents((0, config_1.getProjectConfig)());
|
|
38
|
-
core_1.CliUx.ux.action.start(`Getting Agent ${args.ref}`);
|
|
39
|
-
const agent = await agents.getAgent(args.ref);
|
|
40
|
-
const jsonObj = {
|
|
41
|
-
Ref: agent.ref,
|
|
42
|
-
Name: agent.name,
|
|
43
|
-
Username: agent.username,
|
|
44
|
-
Privacy: (0, utils_1.toPascalCase)(agent.privacy),
|
|
45
|
-
Domains: agent.domains.join(","),
|
|
46
|
-
Created: moment(agent.createTime).fromNow(),
|
|
47
|
-
Updated: moment(agent.updateTime).fromNow()
|
|
48
|
-
};
|
|
49
|
-
await core_1.CliUx.ux.wait(1000);
|
|
50
|
-
core_1.CliUx.ux.action.stop("");
|
|
51
|
-
console.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
throw new errors_1.CLIError(e.message);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
GetCommand.description = "get a Fonoster Agent";
|
|
59
|
-
GetCommand.args = [{ name: "ref" }];
|
|
60
|
-
exports.default = GetCommand;
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
5
|
-
* http://github.com/fonoster/fonoster
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Fonoster
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License (the "License");
|
|
10
|
-
* you may not use this file except in compliance with
|
|
11
|
-
* the License. You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* https://opensource.org/licenses/MIT
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
require("../../config");
|
|
22
|
-
const errors_1 = require("@oclif/errors");
|
|
23
|
-
const command_1 = require("@oclif/command");
|
|
24
|
-
const agents_1 = require("@fonoster/agents");
|
|
25
|
-
const core_1 = require("@oclif/core");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Agents = require("@fonoster/agents");
|
|
28
|
-
const inquirer = require("inquirer");
|
|
29
|
-
class ListCommand extends command_1.Command {
|
|
30
|
-
async run() {
|
|
31
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
32
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
33
|
-
}
|
|
34
|
-
const { flags } = this.parse(ListCommand);
|
|
35
|
-
try {
|
|
36
|
-
const agents = new Agents((0, config_1.getProjectConfig)());
|
|
37
|
-
let firstBatch = true;
|
|
38
|
-
let pageToken = "1";
|
|
39
|
-
const pageSize = flags.size;
|
|
40
|
-
const view = agents_1.CommonPB.View.BASIC;
|
|
41
|
-
while (true) {
|
|
42
|
-
// Get a list
|
|
43
|
-
const result = await agents.listAgents({ pageSize, pageToken, view });
|
|
44
|
-
const list = result.agents;
|
|
45
|
-
pageToken = result.nextPageToken;
|
|
46
|
-
// Dont ask this if is the first time or empty data
|
|
47
|
-
if (list.length > 0 && !firstBatch) {
|
|
48
|
-
const answer = await inquirer.prompt([
|
|
49
|
-
{ name: "q", message: "More", type: "confirm" }
|
|
50
|
-
]);
|
|
51
|
-
if (!answer.q)
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
if (list.length < 1)
|
|
55
|
-
break;
|
|
56
|
-
const showTable = (showHeader, data) => {
|
|
57
|
-
core_1.CliUx.ux.table(data, {
|
|
58
|
-
ref: { minWidth: 12 },
|
|
59
|
-
name: { header: "Name", minWidth: 12 },
|
|
60
|
-
username: { header: "Username", minWidth: 12 },
|
|
61
|
-
privacy: { header: "Privacy", minWidth: 12, extended: true },
|
|
62
|
-
domains: {
|
|
63
|
-
header: "Domains",
|
|
64
|
-
minWidth: 12,
|
|
65
|
-
get: (row) => `${row.domains.join(",")}`
|
|
66
|
-
}
|
|
67
|
-
}, { "no-header": !showHeader });
|
|
68
|
-
};
|
|
69
|
-
showTable(firstBatch, list);
|
|
70
|
-
firstBatch = false;
|
|
71
|
-
if (!pageToken)
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
throw new errors_1.CLIError(e.message);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
ListCommand.description = `list all Fonoster Agents you have access to
|
|
81
|
-
...
|
|
82
|
-
List all Fonoster Agents you have access to
|
|
83
|
-
`;
|
|
84
|
-
ListCommand.flags = {
|
|
85
|
-
size: command_1.flags.integer({
|
|
86
|
-
char: "s",
|
|
87
|
-
default: 25,
|
|
88
|
-
description: "agent of result per page"
|
|
89
|
-
})
|
|
90
|
-
};
|
|
91
|
-
ListCommand.aliases = ["agents:ls"];
|
|
92
|
-
exports.default = ListCommand;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
5
|
-
* http://github.com/fonoster/fonoster
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Fonoster
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License (the "License");
|
|
10
|
-
* you may not use this file except in compliance with
|
|
11
|
-
* the License. You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* https://opensource.org/licenses/MIT
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
require("../../config");
|
|
22
|
-
const errors_1 = require("@oclif/errors");
|
|
23
|
-
const command_1 = require("@oclif/command");
|
|
24
|
-
const core_1 = require("@oclif/core");
|
|
25
|
-
const config_1 = require("../../config");
|
|
26
|
-
const utils_1 = require("../../utils");
|
|
27
|
-
const { Privacy } = require("@fonoster/agents");
|
|
28
|
-
const Agents = require("@fonoster/agents");
|
|
29
|
-
const inquirer = require("inquirer");
|
|
30
|
-
class UpdateCommand extends command_1.Command {
|
|
31
|
-
async run() {
|
|
32
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
33
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
34
|
-
}
|
|
35
|
-
console.log("This utility will help you update an existing Agent");
|
|
36
|
-
console.log("Press ^C at any time to quit.");
|
|
37
|
-
const { args } = this.parse(UpdateCommand);
|
|
38
|
-
const agents = new Agents((0, config_1.getProjectConfig)());
|
|
39
|
-
const agent = await agents.getAgent(args.ref);
|
|
40
|
-
const answers = await inquirer.prompt([
|
|
41
|
-
{
|
|
42
|
-
name: "name",
|
|
43
|
-
message: "friendly name",
|
|
44
|
-
type: "input",
|
|
45
|
-
default: agent.name
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "secret",
|
|
49
|
-
message: "secret",
|
|
50
|
-
type: "password",
|
|
51
|
-
mask: true
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: "privacy",
|
|
55
|
-
message: "privacy",
|
|
56
|
-
type: "list",
|
|
57
|
-
choices: [(0, utils_1.toPascalCase)(Privacy.NONE), (0, utils_1.toPascalCase)(Privacy.PRIVATE)],
|
|
58
|
-
default: (0, utils_1.toPascalCase)(agent.privacy)
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: "confirm",
|
|
62
|
-
message: "ready?",
|
|
63
|
-
type: "confirm"
|
|
64
|
-
}
|
|
65
|
-
]);
|
|
66
|
-
answers.ref = args.ref;
|
|
67
|
-
if (!answers.confirm) {
|
|
68
|
-
console.log("Aborted");
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
try {
|
|
72
|
-
core_1.CliUx.ux.action.start(`Updating agent ${answers.name}`);
|
|
73
|
-
answers.privacy = Privacy[answers.privacy.toUpperCase()];
|
|
74
|
-
await agents.updateAgent(answers);
|
|
75
|
-
await core_1.CliUx.ux.wait(1000);
|
|
76
|
-
core_1.CliUx.ux.action.stop("Done");
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
core_1.CliUx.ux.action.stop();
|
|
80
|
-
throw new errors_1.CLIError(e.message);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
UpdateCommand.args = [{ name: "ref" }];
|
|
86
|
-
UpdateCommand.description = `update a Fonoster Agent
|
|
87
|
-
...
|
|
88
|
-
Update a Fonoster Agent
|
|
89
|
-
`;
|
|
90
|
-
exports.default = UpdateCommand;
|
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
/*
|
|
10
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
11
|
-
* http://github.com/fonoster/fonoster
|
|
12
|
-
*
|
|
13
|
-
* This file is part of Fonoster
|
|
14
|
-
*
|
|
15
|
-
* Licensed under the MIT License (the "License");
|
|
16
|
-
* you may not use this file except in compliance with
|
|
17
|
-
* the License. You may obtain a copy of the License at
|
|
18
|
-
*
|
|
19
|
-
* https://opensource.org/licenses/MIT
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
-
* See the License for the specific language governing permissions and
|
|
25
|
-
* limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
require("../../config");
|
|
28
|
-
const errors_1 = require("@oclif/errors");
|
|
29
|
-
const command_1 = require("@oclif/command");
|
|
30
|
-
const core_1 = require("@oclif/core");
|
|
31
|
-
const config_1 = require("../../config");
|
|
32
|
-
const project_guard_1 = require("../../decorators/project_guard");
|
|
33
|
-
const voices_1 = require("../../data/voices");
|
|
34
|
-
const Apps = require("@fonoster/apps");
|
|
35
|
-
const Secrets = require("@fonoster/secrets");
|
|
36
|
-
const inquirer = require("inquirer");
|
|
37
|
-
const validator = (value, message = "This field is required") => Boolean(value?.trim()?.length) || message;
|
|
38
|
-
class CreateCommand extends command_1.Command {
|
|
39
|
-
async run() {
|
|
40
|
-
console.log("This utility will help you create a new Fonoster App");
|
|
41
|
-
console.log("Press ^C at any time to quit.\n");
|
|
42
|
-
try {
|
|
43
|
-
const { secrets: response } = await new Secrets((0, config_1.getProjectConfig)()).listSecrets({
|
|
44
|
-
pageSize: 25,
|
|
45
|
-
pageToken: "1"
|
|
46
|
-
});
|
|
47
|
-
const secrets = response.map(({ name }) => name) || [];
|
|
48
|
-
if (secrets.length === 0) {
|
|
49
|
-
throw new errors_1.CLIError("Before adding a App you must create a Secret");
|
|
50
|
-
}
|
|
51
|
-
const answers = await inquirer.prompt([
|
|
52
|
-
{
|
|
53
|
-
name: "name",
|
|
54
|
-
message: "Application Name",
|
|
55
|
-
type: "input",
|
|
56
|
-
validate: (value) => validator(value, "You must enter a name for your Application, try something friendly.")
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "speechConfig.voice",
|
|
60
|
-
message: "Voice name",
|
|
61
|
-
type: "list",
|
|
62
|
-
choices: voices_1.voices,
|
|
63
|
-
validate: (value) => validator(value, "You must select a voice")
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "speechConfig.secretName",
|
|
67
|
-
message: "Speech Config Secret",
|
|
68
|
-
type: "list",
|
|
69
|
-
choices: secrets,
|
|
70
|
-
validate: (value) => validator(value, "You must select a Secret")
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "intentsEngineConfig.welcomeIntentId",
|
|
74
|
-
message: "Type the welcome intent ID (e.g. WELCOME)",
|
|
75
|
-
type: "input"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: "engine",
|
|
79
|
-
message: "Select Intents Engine Type",
|
|
80
|
-
type: "list",
|
|
81
|
-
choices: ["DialogflowES"],
|
|
82
|
-
validate: (value) => validator(value, "You must select a engine")
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: "intentsEngineConfig.projectId",
|
|
86
|
-
message: "Type a project ID",
|
|
87
|
-
type: "input",
|
|
88
|
-
validate: (value) => validator(value, "You must enter a project ID for your Application.")
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: "intentsEngineConfig.secretName",
|
|
92
|
-
message: "Intents Engine Secret",
|
|
93
|
-
type: "list",
|
|
94
|
-
choices: secrets,
|
|
95
|
-
validate: (value) => validator(value, "You must select a Secret")
|
|
96
|
-
},
|
|
97
|
-
// Disabling this until we bring support for Dialogflow CX
|
|
98
|
-
/* {
|
|
99
|
-
name: "intentsEngineConfig.agent",
|
|
100
|
-
message: "Type an Agent",
|
|
101
|
-
type: "input",
|
|
102
|
-
when: (answers) => answers.engine === "DialogflowES",
|
|
103
|
-
validate: (value: string) =>
|
|
104
|
-
validator(value, "You must enter a agent for your Application.")
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: "intentsEngineConfig.location",
|
|
108
|
-
message: "Type a Location",
|
|
109
|
-
type: "input",
|
|
110
|
-
when: (answers) => answers.engine === "DialogflowES",
|
|
111
|
-
validate: (value: string) =>
|
|
112
|
-
validator(value, "You must enter a location for your Application.")
|
|
113
|
-
},*/
|
|
114
|
-
{
|
|
115
|
-
name: "showAdvanceOptions",
|
|
116
|
-
message: "Show advance options?",
|
|
117
|
-
type: "confirm"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: "initialDtmf",
|
|
121
|
-
message: "Initial DTMF (optional)",
|
|
122
|
-
type: "input",
|
|
123
|
-
when: (answers) => answers.showAdvanceOptions,
|
|
124
|
-
validate: (value) => {
|
|
125
|
-
const regex = /^[0-9*#]*$/;
|
|
126
|
-
if (value && !regex.test(value)) {
|
|
127
|
-
return "You must enter a valid DTMF. It’s a string that allows 1234567890#*";
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "enableEvents",
|
|
134
|
-
message: "Enable Events",
|
|
135
|
-
type: "confirm",
|
|
136
|
-
when: (answers) => answers.showAdvanceOptions
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "activationIntentId",
|
|
140
|
-
message: "Type the activation intent ID (optional)",
|
|
141
|
-
type: "input",
|
|
142
|
-
when: (answers) => answers.showAdvanceOptions
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "activationTimeout",
|
|
146
|
-
message: "Type the activation timeout (e.g. 15000)",
|
|
147
|
-
type: "input",
|
|
148
|
-
when: (answers) => answers.showAdvanceOptions,
|
|
149
|
-
validate: (value) => {
|
|
150
|
-
const regex = /^[0-9]*$/;
|
|
151
|
-
if (value && !regex.test(value)) {
|
|
152
|
-
return "You must enter a valid timeout. It’s a number in milliseconds";
|
|
153
|
-
}
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
name: "interactionTimeout",
|
|
159
|
-
message: "Type the interaction timeout (e.g. 10000)",
|
|
160
|
-
type: "input",
|
|
161
|
-
when: (answers) => answers.showAdvanceOptions,
|
|
162
|
-
validate: (value) => {
|
|
163
|
-
const regex = /^[0-9]*$/;
|
|
164
|
-
if (value && !regex.test(value)) {
|
|
165
|
-
return "You must enter a valid timeout. It’s a number in milliseconds";
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
name: "transferConfig.message",
|
|
172
|
-
message: "Type a transfer message (e.g. Please wait while we transfer your call.)",
|
|
173
|
-
type: "input",
|
|
174
|
-
when: (answers) => answers.showAdvanceOptions
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
name: "intentsEngineConfig.emulateTelephonyPlatform",
|
|
178
|
-
message: "Emulate Telephony Platform",
|
|
179
|
-
type: "confirm",
|
|
180
|
-
when: (answers) => answers.showAdvanceOptions
|
|
181
|
-
}
|
|
182
|
-
]);
|
|
183
|
-
const confirmPrompt = await inquirer.prompt([
|
|
184
|
-
{
|
|
185
|
-
name: "confirm",
|
|
186
|
-
message: "Ready to create your App?",
|
|
187
|
-
type: "confirm"
|
|
188
|
-
}
|
|
189
|
-
]);
|
|
190
|
-
if (!confirmPrompt.confirm)
|
|
191
|
-
return console.log("Aborted");
|
|
192
|
-
core_1.CliUx.ux.action.start(`Creating App ${answers.name}`);
|
|
193
|
-
const apps = new Apps((0, config_1.getProjectConfig)());
|
|
194
|
-
delete answers.showAdvanceOptions;
|
|
195
|
-
delete answers.engine;
|
|
196
|
-
const result = await apps.createApp(answers);
|
|
197
|
-
await core_1.CliUx.ux.wait(1000);
|
|
198
|
-
core_1.CliUx.ux.action.stop(result.ref);
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
core_1.CliUx.ux.action.stop();
|
|
202
|
-
throw new errors_1.CLIError(e.code === 9 ? "This App already exist" : e.message);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
CreateCommand.description = `create a new Fonoster App
|
|
207
|
-
...
|
|
208
|
-
Create a new Fonoster App
|
|
209
|
-
`;
|
|
210
|
-
__decorate([
|
|
211
|
-
(0, project_guard_1.ProjectGuard)()
|
|
212
|
-
], CreateCommand.prototype, "run", null);
|
|
213
|
-
exports.default = CreateCommand;
|