@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,130 +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 domains_1 = require("@fonoster/domains");
|
|
23
|
-
const errors_1 = require("@oclif/errors");
|
|
24
|
-
const command_1 = require("@oclif/command");
|
|
25
|
-
const core_1 = require("@oclif/core");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Numbers = require("@fonoster/numbers");
|
|
28
|
-
const Domains = require("@fonoster/domains");
|
|
29
|
-
const inquirer = require("inquirer");
|
|
30
|
-
const view = domains_1.CommonPB.View.BASIC;
|
|
31
|
-
class CreateCommand 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 Fonoster Domain");
|
|
37
|
-
console.log("Press ^C at any time to quit.");
|
|
38
|
-
const numbers = new Numbers((0, config_1.getProjectConfig)());
|
|
39
|
-
const result = await numbers.listNumbers({
|
|
40
|
-
pageSize: 20,
|
|
41
|
-
pageToken: "1",
|
|
42
|
-
view
|
|
43
|
-
});
|
|
44
|
-
const nums = result.numbers.map((n) => {
|
|
45
|
-
return {
|
|
46
|
-
value: n.ref,
|
|
47
|
-
name: n.e164Number
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
nums.unshift({
|
|
51
|
-
value: "none",
|
|
52
|
-
name: "none"
|
|
53
|
-
});
|
|
54
|
-
const answers = await inquirer.prompt([
|
|
55
|
-
{
|
|
56
|
-
name: "name",
|
|
57
|
-
message: "friendly name",
|
|
58
|
-
type: "input"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: "domainUri",
|
|
62
|
-
message: "domain uri (e.g acme)",
|
|
63
|
-
type: "input"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "egressNumberRef",
|
|
67
|
-
message: "egress number",
|
|
68
|
-
type: "list",
|
|
69
|
-
choices: nums,
|
|
70
|
-
default: "none"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "egressRule",
|
|
74
|
-
message: "egress rule",
|
|
75
|
-
type: "input",
|
|
76
|
-
default: ".*"
|
|
77
|
-
},
|
|
78
|
-
/* {
|
|
79
|
-
name: 'accessDeny',
|
|
80
|
-
message: 'access deny list',
|
|
81
|
-
type: 'input',
|
|
82
|
-
default: '0.0.0.0/1'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: 'accessAllow',
|
|
86
|
-
message: 'access allow list',
|
|
87
|
-
type: 'input'
|
|
88
|
-
},*/
|
|
89
|
-
{
|
|
90
|
-
name: "confirm",
|
|
91
|
-
message: "ready?",
|
|
92
|
-
type: "confirm"
|
|
93
|
-
}
|
|
94
|
-
]);
|
|
95
|
-
if (!answers.confirm) {
|
|
96
|
-
console.log("Aborted");
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
try {
|
|
100
|
-
const accessDeny = answers.accessDeny;
|
|
101
|
-
const accessAllow = answers.accessAllow;
|
|
102
|
-
answers.accessDeny = accessDeny ? accessDeny.split(",") : [];
|
|
103
|
-
answers.accessAllow = accessAllow ? accessAllow.split(",") : [];
|
|
104
|
-
if (!answers.egressNumberRef || answers.egressNumberRef === "none") {
|
|
105
|
-
delete answers.egressRule;
|
|
106
|
-
delete answers.egressNumberRef;
|
|
107
|
-
}
|
|
108
|
-
core_1.CliUx.ux.action.start(`Creating Domain ${answers.name}`);
|
|
109
|
-
const domains = new Domains((0, config_1.getProjectConfig)());
|
|
110
|
-
const domain = await domains.createDomain(answers);
|
|
111
|
-
await core_1.CliUx.ux.wait(1000);
|
|
112
|
-
core_1.CliUx.ux.action.stop(domain.ref);
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
core_1.CliUx.ux.action.stop();
|
|
116
|
-
if (e.code === 9) {
|
|
117
|
-
throw new errors_1.CLIError("This Domain already exist");
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
throw new errors_1.CLIError(e.message);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
CreateCommand.description = `create a new Fonoster Domain
|
|
127
|
-
...
|
|
128
|
-
Create a new Fonoster Domain
|
|
129
|
-
`;
|
|
130
|
-
exports.default = CreateCommand;
|
|
@@ -1,49 +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 errors_1 = require("@oclif/errors");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Domains = require("@fonoster/domains");
|
|
28
|
-
class DeleteCommand 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
|
-
try {
|
|
34
|
-
await super.deleteResource(new Domains((0, config_1.getProjectConfig)()), "deleteDomain");
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
if (e.code === 9) {
|
|
38
|
-
throw new errors_1.CLIError("unable to delete: first ensure there are no Agents under this Fonoster Domain");
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
throw new errors_1.CLIError(e.message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
DeleteCommand.description = "delete a Fonoster Domain";
|
|
47
|
-
DeleteCommand.args = [{ name: "ref" }];
|
|
48
|
-
DeleteCommand.aliases = ["domains:del", "domains:rm"];
|
|
49
|
-
exports.default = DeleteCommand;
|
|
@@ -1,63 +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 Domains = require("@fonoster/domains");
|
|
28
|
-
const moment = require("moment");
|
|
29
|
-
class GetCommand 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 { args } = this.parse(GetCommand);
|
|
35
|
-
try {
|
|
36
|
-
const domains = new Domains((0, config_1.getProjectConfig)());
|
|
37
|
-
core_1.CliUx.ux.action.start(`Getting domain ${args.ref}`);
|
|
38
|
-
const domain = await domains.getDomain(args.ref);
|
|
39
|
-
console.log("geting domain: ");
|
|
40
|
-
const allow = domain.accessDeny.length > 0 ? domain.accessDeny.join(",") : "None";
|
|
41
|
-
const deny = domain.accessAllow.length > 0 ? domain.accessAllow.join(",") : "None";
|
|
42
|
-
const jsonObj = {
|
|
43
|
-
Name: domain.name,
|
|
44
|
-
"Domain URI": domain.domainUri,
|
|
45
|
-
"Egress Rule": domain.egressRule || "None",
|
|
46
|
-
"Egress Number Ref": domain.egressNumberRef || "None",
|
|
47
|
-
"Access Deny List": deny,
|
|
48
|
-
"Access Allow List": allow,
|
|
49
|
-
Created: moment(domain.createTime).fromNow(),
|
|
50
|
-
Updated: moment(domain.updateTime).fromNow()
|
|
51
|
-
};
|
|
52
|
-
await core_1.CliUx.ux.wait(1000);
|
|
53
|
-
core_1.CliUx.ux.action.stop("");
|
|
54
|
-
console.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
throw new errors_1.CLIError(e.message);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
GetCommand.description = "get a Fonoster Domain";
|
|
62
|
-
GetCommand.args = [{ name: "ref" }];
|
|
63
|
-
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,95 +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 domains_1 = require("@fonoster/domains");
|
|
23
|
-
const errors_1 = require("@oclif/errors");
|
|
24
|
-
const command_1 = require("@oclif/command");
|
|
25
|
-
const core_1 = require("@oclif/core");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Domains = require("@fonoster/domains");
|
|
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 domains = new Domains((0, config_1.getProjectConfig)());
|
|
37
|
-
let firstBatch = true;
|
|
38
|
-
let pageToken = "1";
|
|
39
|
-
const pageSize = flags.size;
|
|
40
|
-
const view = domains_1.CommonPB.View.BASIC;
|
|
41
|
-
while (true) {
|
|
42
|
-
// Get a list
|
|
43
|
-
const result = await domains.listDomains({ pageSize, pageToken, view });
|
|
44
|
-
const list = result.domains;
|
|
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: 15 },
|
|
59
|
-
name: { header: "Name", minWidth: 15 },
|
|
60
|
-
domainUri: { header: "Domain URI", minWidth: 15 },
|
|
61
|
-
egressRule: {
|
|
62
|
-
header: "Egress Rule",
|
|
63
|
-
minWidth: 15,
|
|
64
|
-
get: (row) => (row.egressNumberRef ? row.egressRule : "na")
|
|
65
|
-
},
|
|
66
|
-
egressNumberRef: {
|
|
67
|
-
header: "Egress Number Ref",
|
|
68
|
-
minWidth: 15
|
|
69
|
-
}
|
|
70
|
-
}, { "no-header": !showHeader });
|
|
71
|
-
};
|
|
72
|
-
showTable(firstBatch, list);
|
|
73
|
-
firstBatch = false;
|
|
74
|
-
if (!pageToken)
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (e) {
|
|
79
|
-
throw new errors_1.CLIError(e.message);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
ListCommand.description = `list all Fonoster Domains you have access to
|
|
84
|
-
...
|
|
85
|
-
List all Fonoster Domains you have access to
|
|
86
|
-
`;
|
|
87
|
-
ListCommand.flags = {
|
|
88
|
-
size: command_1.flags.integer({
|
|
89
|
-
char: "s",
|
|
90
|
-
default: 25,
|
|
91
|
-
description: "number of result per page"
|
|
92
|
-
})
|
|
93
|
-
};
|
|
94
|
-
ListCommand.aliases = ["domains:ls"];
|
|
95
|
-
exports.default = ListCommand;
|
|
@@ -1,124 +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 domains_1 = require("@fonoster/domains");
|
|
23
|
-
const errors_1 = require("@oclif/errors");
|
|
24
|
-
const command_1 = require("@oclif/command");
|
|
25
|
-
const core_1 = require("@oclif/core");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Numbers = require("@fonoster/numbers");
|
|
28
|
-
const Domains = require("@fonoster/domains");
|
|
29
|
-
const inquirer = require("inquirer");
|
|
30
|
-
const view = domains_1.CommonPB.View.BASIC;
|
|
31
|
-
class UpdateCommand 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 update an existing Fonoster Domain");
|
|
37
|
-
console.log("to help you get start quickly. Press ^C at any time to quit.");
|
|
38
|
-
const { args } = this.parse(UpdateCommand);
|
|
39
|
-
const domains = new Domains((0, config_1.getProjectConfig)());
|
|
40
|
-
const numbers = new Numbers((0, config_1.getProjectConfig)());
|
|
41
|
-
const domain = await domains.getDomain(args.ref);
|
|
42
|
-
const result = await numbers.listNumbers({
|
|
43
|
-
pageSize: 20,
|
|
44
|
-
pageToken: "1",
|
|
45
|
-
view
|
|
46
|
-
});
|
|
47
|
-
const nums = result.numbers.map((n) => {
|
|
48
|
-
return {
|
|
49
|
-
value: n.ref,
|
|
50
|
-
name: n.e164Number
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
nums.unshift({
|
|
54
|
-
value: "none",
|
|
55
|
-
name: "none"
|
|
56
|
-
});
|
|
57
|
-
const answers = await inquirer.prompt([
|
|
58
|
-
{
|
|
59
|
-
name: "name",
|
|
60
|
-
message: "domain name",
|
|
61
|
-
type: "input",
|
|
62
|
-
default: domain.name
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: "egressRule",
|
|
66
|
-
message: "egress rule",
|
|
67
|
-
type: "input",
|
|
68
|
-
default: domain.egressRule
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: "egressNumberRef",
|
|
72
|
-
message: "egress number",
|
|
73
|
-
type: "list",
|
|
74
|
-
choices: nums,
|
|
75
|
-
default: "none"
|
|
76
|
-
},
|
|
77
|
-
/*
|
|
78
|
-
{
|
|
79
|
-
name: "accessDeny",
|
|
80
|
-
message: "access deny list",
|
|
81
|
-
type: "input",
|
|
82
|
-
default: domain.accessDeny.join(",")
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: "accessAllow",
|
|
86
|
-
message: "access allow list",
|
|
87
|
-
type: "input",
|
|
88
|
-
default: domain.accessAllow.join(",")
|
|
89
|
-
},
|
|
90
|
-
*/
|
|
91
|
-
{
|
|
92
|
-
name: "confirm",
|
|
93
|
-
message: "ready?",
|
|
94
|
-
type: "confirm"
|
|
95
|
-
}
|
|
96
|
-
]);
|
|
97
|
-
answers.ref = args.ref;
|
|
98
|
-
if (!answers.confirm) {
|
|
99
|
-
console.log("Aborted");
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
try {
|
|
103
|
-
const accessDeny = answers.accessDeny;
|
|
104
|
-
const accessAllow = answers.accessAllow;
|
|
105
|
-
answers.accessDeny = accessDeny ? accessDeny.split(",") : [];
|
|
106
|
-
answers.accessAllow = accessAllow ? accessAllow.split(",") : [];
|
|
107
|
-
core_1.CliUx.ux.action.start(`Updating domain ${answers.name}`);
|
|
108
|
-
await domains.updateDomain(answers);
|
|
109
|
-
await core_1.CliUx.ux.wait(1000);
|
|
110
|
-
core_1.CliUx.ux.action.stop("Done");
|
|
111
|
-
}
|
|
112
|
-
catch (e) {
|
|
113
|
-
core_1.CliUx.ux.action.stop();
|
|
114
|
-
throw new errors_1.CLIError(e.message);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
UpdateCommand.args = [{ name: "ref" }];
|
|
120
|
-
UpdateCommand.description = `update a Fonoster Domain
|
|
121
|
-
...
|
|
122
|
-
Update a Fonoster Domain
|
|
123
|
-
`;
|
|
124
|
-
exports.default = UpdateCommand;
|
|
@@ -1,117 +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 numbers_1 = require("@fonoster/numbers");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Providers = require("@fonoster/providers");
|
|
28
|
-
const Numbers = require("@fonoster/numbers");
|
|
29
|
-
const inquirer = require("inquirer");
|
|
30
|
-
class CreateCommand 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 create a new Fonoster Number");
|
|
36
|
-
console.log("Press ^C at any time to quit.");
|
|
37
|
-
const view = numbers_1.CommonPB.View.BASIC;
|
|
38
|
-
try {
|
|
39
|
-
const response = await new Providers((0, config_1.getProjectConfig)()).listProviders({
|
|
40
|
-
pageSize: 25,
|
|
41
|
-
pageToken: "1"
|
|
42
|
-
});
|
|
43
|
-
const providers = response.providers.map((p) => {
|
|
44
|
-
const obj = {};
|
|
45
|
-
obj.name = p.name;
|
|
46
|
-
obj.value = p.ref;
|
|
47
|
-
return obj;
|
|
48
|
-
});
|
|
49
|
-
if (providers.length === 0) {
|
|
50
|
-
throw new Error("before adding a Number you must create a Provider (trunk)");
|
|
51
|
-
}
|
|
52
|
-
const answers = await inquirer.prompt([
|
|
53
|
-
{
|
|
54
|
-
name: "e164Number",
|
|
55
|
-
message: "number in E.164 format (e.g. +16471234567)",
|
|
56
|
-
type: "input"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: "providerRef",
|
|
60
|
-
message: "service provider",
|
|
61
|
-
type: "list",
|
|
62
|
-
choices: providers
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: "aorLink",
|
|
66
|
-
message: "address of record",
|
|
67
|
-
type: "input",
|
|
68
|
-
default: null
|
|
69
|
-
}
|
|
70
|
-
]);
|
|
71
|
-
if (!answers.aorLink) {
|
|
72
|
-
const webhookPrompt = await inquirer.prompt([
|
|
73
|
-
{
|
|
74
|
-
name: "webhook",
|
|
75
|
-
message: "webhook",
|
|
76
|
-
type: "input",
|
|
77
|
-
default: null
|
|
78
|
-
}
|
|
79
|
-
]);
|
|
80
|
-
answers.ingressInfo = {};
|
|
81
|
-
answers.ingressInfo.webhook = webhookPrompt.webhook;
|
|
82
|
-
}
|
|
83
|
-
const confirmPrompt = await inquirer.prompt([
|
|
84
|
-
{
|
|
85
|
-
name: "confirm",
|
|
86
|
-
message: "ready?",
|
|
87
|
-
type: "confirm"
|
|
88
|
-
}
|
|
89
|
-
]);
|
|
90
|
-
answers.confirm = confirmPrompt.confirm;
|
|
91
|
-
if (!answers.confirm) {
|
|
92
|
-
console.log("Aborted");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
core_1.CliUx.ux.action.start(`Creating Number ${answers.e164Number}`);
|
|
96
|
-
const numbers = new Numbers((0, config_1.getProjectConfig)());
|
|
97
|
-
const result = await numbers.createNumber(answers);
|
|
98
|
-
await core_1.CliUx.ux.wait(1000);
|
|
99
|
-
core_1.CliUx.ux.action.stop(result.ref);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
core_1.CliUx.ux.action.stop();
|
|
104
|
-
if (e.code === 9) {
|
|
105
|
-
throw new errors_1.CLIError("This Number already exist");
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
throw new errors_1.CLIError(e.message);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
CreateCommand.description = `create a new Fonoster Number
|
|
114
|
-
...
|
|
115
|
-
Create a new Fonoster Number
|
|
116
|
-
`;
|
|
117
|
-
exports.default = CreateCommand;
|