@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,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 config_1 = require("../../config");
|
|
26
|
-
const Projects = require("@fonoster/projects");
|
|
27
|
-
class UpdateCommand extends command_1.Command {
|
|
28
|
-
async run() {
|
|
29
|
-
const { args } = this.parse(UpdateCommand);
|
|
30
|
-
try {
|
|
31
|
-
const projects = new Projects();
|
|
32
|
-
const project = await projects.getProject(args.ref);
|
|
33
|
-
core_1.CliUx.ux.action.start(`Setting default Project to ${args.ref}`);
|
|
34
|
-
const config = (0, config_1.getConfig)();
|
|
35
|
-
const { accessKeyId, accessKeySecret, endpoint } = config;
|
|
36
|
-
(0, config_1.setConfig)({
|
|
37
|
-
endpoint,
|
|
38
|
-
accessKeyId,
|
|
39
|
-
accessKeySecret,
|
|
40
|
-
defaultProject: {
|
|
41
|
-
name: project.name,
|
|
42
|
-
accessKeyId: project.accessKeyId,
|
|
43
|
-
accessKeySecret: project.accessKeySecret
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
await core_1.CliUx.ux.wait(1000);
|
|
47
|
-
core_1.CliUx.ux.action.stop("Done");
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
core_1.CliUx.ux.action.stop();
|
|
51
|
-
throw new errors_1.CLIError(e.message);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
UpdateCommand.args = [{ name: "ref" }];
|
|
56
|
-
UpdateCommand.description = `set a default Fonoster Project
|
|
57
|
-
...
|
|
58
|
-
Set a default Fonoster Project
|
|
59
|
-
`;
|
|
60
|
-
exports.default = UpdateCommand;
|
|
@@ -1,114 +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 Providers = require("@fonoster/providers");
|
|
27
|
-
const inquirer = require("inquirer");
|
|
28
|
-
class CreateCommand extends command_1.Command {
|
|
29
|
-
async run() {
|
|
30
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
31
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
32
|
-
}
|
|
33
|
-
console.log("This utility will help you create a new Fonoster Provider");
|
|
34
|
-
console.log("Press ^C at any time to quit.");
|
|
35
|
-
const answers = await inquirer.prompt([
|
|
36
|
-
{
|
|
37
|
-
name: "name",
|
|
38
|
-
message: "friendly name",
|
|
39
|
-
type: "input"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "username",
|
|
43
|
-
message: "username",
|
|
44
|
-
type: "input"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: "secret",
|
|
48
|
-
message: "secret",
|
|
49
|
-
type: "password",
|
|
50
|
-
mask: true
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: "host",
|
|
54
|
-
message: "host",
|
|
55
|
-
type: "input"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "transport",
|
|
59
|
-
message: "transport",
|
|
60
|
-
type: "list",
|
|
61
|
-
choices: ["tcp", "udp"],
|
|
62
|
-
default: "tcp"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: "register",
|
|
66
|
-
message: "enable registration?",
|
|
67
|
-
type: "confirm"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "expires",
|
|
71
|
-
message: "sip registration refresh (in seconds)",
|
|
72
|
-
type: "input",
|
|
73
|
-
validate: (answer) => {
|
|
74
|
-
if (isNaN(answer)) {
|
|
75
|
-
return "please enter a number";
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
},
|
|
79
|
-
default: 600
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "confirm",
|
|
83
|
-
message: "ready?",
|
|
84
|
-
type: "confirm"
|
|
85
|
-
}
|
|
86
|
-
]);
|
|
87
|
-
if (!answers.confirm) {
|
|
88
|
-
console.log("Aborted");
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
try {
|
|
92
|
-
core_1.CliUx.ux.action.start(`Creating Provider ${answers.name}`);
|
|
93
|
-
const providers = new Providers((0, config_1.getProjectConfig)());
|
|
94
|
-
const provider = await providers.createProvider(answers);
|
|
95
|
-
await core_1.CliUx.ux.wait(1000);
|
|
96
|
-
core_1.CliUx.ux.action.stop(provider.ref);
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
core_1.CliUx.ux.action.stop();
|
|
100
|
-
if (e.code === 9) {
|
|
101
|
-
throw new errors_1.CLIError("This Provider already exist");
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
throw new errors_1.CLIError(e.message);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
CreateCommand.description = `create a new Fonoster Provider (trunk)
|
|
111
|
-
...
|
|
112
|
-
Create a new Fonoster Provider
|
|
113
|
-
`;
|
|
114
|
-
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 Providers = require("@fonoster/providers");
|
|
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 Providers((0, config_1.getProjectConfig)()), "deleteProvider");
|
|
35
|
-
}
|
|
36
|
-
catch (e) {
|
|
37
|
-
if (e.code === 9) {
|
|
38
|
-
throw new errors_1.CLIError("unable to delete: first ensure there are no Numbers under this Fonoster Provider");
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
throw new errors_1.CLIError(e.message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
DeleteCommand.description = "delete a Fonoster Provider";
|
|
47
|
-
DeleteCommand.args = [{ name: "ref" }];
|
|
48
|
-
DeleteCommand.aliases = ["providers:del", "providers:rm"];
|
|
49
|
-
exports.default = DeleteCommand;
|
|
@@ -1,61 +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 Providers = require("@fonoster/providers");
|
|
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 providers = new Providers((0, config_1.getProjectConfig)());
|
|
37
|
-
core_1.CliUx.ux.action.start(`getting provider ${args.ref}`);
|
|
38
|
-
const provider = await providers.getProvider(args.ref);
|
|
39
|
-
const jsonObj = {
|
|
40
|
-
Ref: provider.ref,
|
|
41
|
-
Name: provider.name,
|
|
42
|
-
Username: provider.username || "(static)",
|
|
43
|
-
Host: provider.host,
|
|
44
|
-
Transport: provider.transport,
|
|
45
|
-
"SIP Registration Refresh": provider.expires,
|
|
46
|
-
Register: provider.register,
|
|
47
|
-
Created: moment(provider.createTime).fromNow(),
|
|
48
|
-
Updated: moment(provider.updateTime).fromNow()
|
|
49
|
-
};
|
|
50
|
-
await core_1.CliUx.ux.wait(1000);
|
|
51
|
-
core_1.CliUx.ux.action.stop("");
|
|
52
|
-
console.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
throw new errors_1.CLIError(e.message);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
GetCommand.description = "get a Fonoster Provider";
|
|
60
|
-
GetCommand.args = [{ name: "ref" }];
|
|
61
|
-
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,98 +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 providers_1 = require("@fonoster/providers");
|
|
25
|
-
const core_1 = require("@oclif/core");
|
|
26
|
-
const config_1 = require("../../config");
|
|
27
|
-
const Providers = require("@fonoster/providers");
|
|
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 providers = new Providers((0, config_1.getProjectConfig)());
|
|
37
|
-
let firstBatch = true;
|
|
38
|
-
let pageToken = "1";
|
|
39
|
-
const pageSize = flags.size;
|
|
40
|
-
const view = providers_1.CommonPB.View.BASIC;
|
|
41
|
-
while (true) {
|
|
42
|
-
// Get a list
|
|
43
|
-
const result = await providers.listProviders({
|
|
44
|
-
pageSize,
|
|
45
|
-
pageToken,
|
|
46
|
-
view
|
|
47
|
-
});
|
|
48
|
-
const list = result.providers;
|
|
49
|
-
pageToken = result.nextPageToken;
|
|
50
|
-
// Dont ask this if is the first time or empty data
|
|
51
|
-
if (list.length > 0 && !firstBatch) {
|
|
52
|
-
const answer = await inquirer.prompt([
|
|
53
|
-
{ name: "q", message: "More", type: "confirm" }
|
|
54
|
-
]);
|
|
55
|
-
if (!answer.q)
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
if (list.length < 1)
|
|
59
|
-
break;
|
|
60
|
-
const showTable = (showHeader, data) => {
|
|
61
|
-
core_1.CliUx.ux.table(data, {
|
|
62
|
-
ref: { minWidth: 13 },
|
|
63
|
-
name: { header: "Name", minWidth: 13 },
|
|
64
|
-
username: {
|
|
65
|
-
header: "Username",
|
|
66
|
-
minWidth: 13,
|
|
67
|
-
get: (row) => row.username || "(static)"
|
|
68
|
-
},
|
|
69
|
-
host: { header: "Host", minWidth: 18 },
|
|
70
|
-
transport: { header: "Transport", minWidth: 13 },
|
|
71
|
-
register: { header: "Register", minWidth: 13 }
|
|
72
|
-
// expires: {header: "SIP Registration Refresh", minWidth: 13}
|
|
73
|
-
}, { "no-header": !showHeader });
|
|
74
|
-
};
|
|
75
|
-
showTable(firstBatch, list);
|
|
76
|
-
firstBatch = false;
|
|
77
|
-
if (!pageToken)
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
throw new errors_1.CLIError(e.message);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
ListCommand.description = `list all Fonoster Providers you have access to
|
|
87
|
-
...
|
|
88
|
-
List all Fonoster Providers you have access to
|
|
89
|
-
`;
|
|
90
|
-
ListCommand.flags = {
|
|
91
|
-
size: command_1.flags.integer({
|
|
92
|
-
char: "s",
|
|
93
|
-
default: 25,
|
|
94
|
-
description: "provider of result per page"
|
|
95
|
-
})
|
|
96
|
-
};
|
|
97
|
-
ListCommand.aliases = ["providers:ls"];
|
|
98
|
-
exports.default = ListCommand;
|
|
@@ -1,113 +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 Providers = require("@fonoster/providers");
|
|
27
|
-
const inquirer = require("inquirer");
|
|
28
|
-
class UpdateCommand extends command_1.Command {
|
|
29
|
-
async run() {
|
|
30
|
-
if (!(0, config_1.hasProjectConfig)()) {
|
|
31
|
-
throw new errors_1.CLIError("you must set a default project");
|
|
32
|
-
}
|
|
33
|
-
const { args } = this.parse(UpdateCommand);
|
|
34
|
-
if (!args.ref)
|
|
35
|
-
throw new Error("please provide the reference of your Fonoster Provider");
|
|
36
|
-
console.log("This utility will help you update an existing Fonoster Provider");
|
|
37
|
-
console.log("Press ^C at any time to quit.");
|
|
38
|
-
const providers = new Providers((0, config_1.getProjectConfig)());
|
|
39
|
-
const provider = await providers.getProvider(args.ref);
|
|
40
|
-
const answers = await inquirer.prompt([
|
|
41
|
-
{
|
|
42
|
-
name: "name",
|
|
43
|
-
message: "friendly name",
|
|
44
|
-
type: "input",
|
|
45
|
-
default: provider.name
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "username",
|
|
49
|
-
message: "username",
|
|
50
|
-
type: "input",
|
|
51
|
-
default: provider.username
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: "secret",
|
|
55
|
-
message: "secret",
|
|
56
|
-
type: "password",
|
|
57
|
-
mask: true
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "host",
|
|
61
|
-
message: "host",
|
|
62
|
-
type: "input",
|
|
63
|
-
default: provider.host
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "transport",
|
|
67
|
-
message: "host",
|
|
68
|
-
type: "list",
|
|
69
|
-
choices: ["tcp", "udp"],
|
|
70
|
-
default: provider.transport
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: "register",
|
|
74
|
-
message: "enable registration?",
|
|
75
|
-
type: "confirm",
|
|
76
|
-
default: provider.register
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "expires",
|
|
80
|
-
message: "sip registration refresh (in seconds)",
|
|
81
|
-
type: "input",
|
|
82
|
-
default: provider.expires
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: "confirm",
|
|
86
|
-
message: "ready?",
|
|
87
|
-
type: "confirm"
|
|
88
|
-
}
|
|
89
|
-
]);
|
|
90
|
-
answers.ref = args.ref;
|
|
91
|
-
if (!answers.confirm) {
|
|
92
|
-
console.log("Aborted");
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
try {
|
|
96
|
-
core_1.CliUx.ux.action.start(`Updating Provider ${answers.name}`);
|
|
97
|
-
await providers.updateProvider(answers);
|
|
98
|
-
await core_1.CliUx.ux.wait(1000);
|
|
99
|
-
core_1.CliUx.ux.action.stop("Done");
|
|
100
|
-
}
|
|
101
|
-
catch (e) {
|
|
102
|
-
core_1.CliUx.ux.action.stop();
|
|
103
|
-
throw new errors_1.CLIError(e.message);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
UpdateCommand.args = [{ name: "ref" }];
|
|
109
|
-
UpdateCommand.description = `update a Fonoster Provider
|
|
110
|
-
...
|
|
111
|
-
Update a Fonoster Provider
|
|
112
|
-
`;
|
|
113
|
-
exports.default = UpdateCommand;
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,69 +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/plugin-funcs
|
|
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 command_1 = require("@oclif/command");
|
|
29
|
-
const errors_1 = require("@oclif/errors");
|
|
30
|
-
const config_1 = require("../../config");
|
|
31
|
-
const project_guard_1 = require("../../decorators/project_guard");
|
|
32
|
-
const getStdin = require("get-stdin-with-tty");
|
|
33
|
-
const Secrets = require("@fonoster/secrets");
|
|
34
|
-
class CreateCommand extends command_1.Command {
|
|
35
|
-
async run() {
|
|
36
|
-
const secretsManager = new Secrets((0, config_1.getProjectConfig)());
|
|
37
|
-
const { args, flags } = this.parse(CreateCommand);
|
|
38
|
-
const secret = flags["from-stdin"]
|
|
39
|
-
? await getStdin()
|
|
40
|
-
: flags["from-literal"];
|
|
41
|
-
if (!args.name || !secret) {
|
|
42
|
-
throw new errors_1.CLIError("Cant create a secret without a name or a secret-value. Type [secrets:create --help] for more information");
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
const result = await secretsManager.createSecret({
|
|
46
|
-
name: args.name,
|
|
47
|
-
secret
|
|
48
|
-
});
|
|
49
|
-
console.log(result.name);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
throw new errors_1.CLIError(e.message);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
CreateCommand.description = "create a Fonoster secret.";
|
|
57
|
-
CreateCommand.args = [{ name: "name" }];
|
|
58
|
-
CreateCommand.flags = {
|
|
59
|
-
help: command_1.flags.help({ char: "h" }),
|
|
60
|
-
"from-literal": command_1.flags.string({
|
|
61
|
-
char: "l",
|
|
62
|
-
description: "pass from literal"
|
|
63
|
-
}),
|
|
64
|
-
"from-stdin": command_1.flags.boolean({ char: "s", description: "pass from stdin" })
|
|
65
|
-
};
|
|
66
|
-
__decorate([
|
|
67
|
-
(0, project_guard_1.ProjectGuard)()
|
|
68
|
-
], CreateCommand.prototype, "run", null);
|
|
69
|
-
exports.default = CreateCommand;
|