@fonoster/ctl 0.7.47 → 0.7.49
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/dist/AuthenticatedCommand.js +5 -5
- package/dist/commands/applications/create.js +1 -1
- package/dist/commands/applications/update.js +11 -11
- package/dist/commands/secrets/update.js +3 -3
- package/dist/commands/sipnet/numbers/get.js +2 -8
- package/dist/commands/sipnet/numbers/linkTwilioNumber.js +2 -6
- package/dist/commands/sipnet/numbers/list.js +0 -7
- package/dist/commands/sipnet/trunks/delete.d.ts +1 -1
- package/dist/commands/sipnet/trunks/delete.js +1 -1
- package/dist/commands/workspaces/{current.d.ts → active.d.ts} +1 -1
- package/dist/commands/workspaces/{current.js → active.js} +18 -7
- package/dist/commands/workspaces/use.js +3 -3
- package/dist/config/getActiveWorkspace.d.ts +3 -0
- package/dist/config/{getCurrentWorkspace.js → getActiveWorkspace.js} +2 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +2 -2
- package/dist/config/setActiveWorkspace.d.ts +3 -0
- package/dist/config/{setCurrentWorkspace.js → setActiveWorkspace.js} +2 -2
- package/package.json +3 -3
- package/dist/config/getCurrentWorkspace.d.ts +0 -3
- package/dist/config/setCurrentWorkspace.d.ts +0 -3
|
@@ -70,17 +70,17 @@ class AuthenticatedCommand extends BaseCommand_1.BaseCommand {
|
|
|
70
70
|
createSdkClient() {
|
|
71
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
72
|
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
73
|
+
const activeWorkspace = (0, config_1.getActiveWorkspace)(workspaces);
|
|
74
|
+
if (!activeWorkspace) {
|
|
75
75
|
throw new Error("No active workspace found. Please login to a Workspace.");
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
78
|
const client = new SDK.Client({
|
|
79
|
-
endpoint:
|
|
80
|
-
accessKeyId: `WO${
|
|
79
|
+
endpoint: activeWorkspace.endpoint,
|
|
80
|
+
accessKeyId: `WO${activeWorkspace.workspaceRef.replaceAll("-", "")}`,
|
|
81
81
|
allowInsecure: this.flags.insecure
|
|
82
82
|
});
|
|
83
|
-
yield client.loginWithApiKey(
|
|
83
|
+
yield client.loginWithApiKey(activeWorkspace.accessKeyId, activeWorkspace.accessKeySecret);
|
|
84
84
|
return client;
|
|
85
85
|
}
|
|
86
86
|
catch (error) {
|
|
@@ -115,7 +115,7 @@ class Create extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
115
115
|
},
|
|
116
116
|
textToSpeech: {
|
|
117
117
|
productRef: yield (0, prompts_1.select)({
|
|
118
|
-
message: "
|
|
118
|
+
message: "TTS Vendor",
|
|
119
119
|
choices: [
|
|
120
120
|
{ name: "Deepgram", value: "tts.deepgram" },
|
|
121
121
|
{ name: "ElevenLabs", value: "tts.elevenlabs" },
|
|
@@ -76,8 +76,8 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
76
76
|
const { args } = yield this.parse(Update);
|
|
77
77
|
const client = yield this.createSdkClient();
|
|
78
78
|
const applications = new SDK.Applications(client);
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
79
|
+
const applicationFromDB = yield applications.getApplication(args.ref);
|
|
80
|
+
if (!applicationFromDB) {
|
|
81
81
|
this.error("Application not found.");
|
|
82
82
|
}
|
|
83
83
|
this.log("This utility will help you update an Application.");
|
|
@@ -86,23 +86,23 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
86
86
|
name: yield (0, prompts_1.input)({
|
|
87
87
|
message: "Name",
|
|
88
88
|
required: true,
|
|
89
|
-
default:
|
|
89
|
+
default: applicationFromDB.name
|
|
90
90
|
}),
|
|
91
91
|
type: yield (0, prompts_1.select)({
|
|
92
92
|
message: "Type",
|
|
93
93
|
choices: [{ name: "External", value: "External" }],
|
|
94
|
-
default:
|
|
94
|
+
default: applicationFromDB.type
|
|
95
95
|
}),
|
|
96
96
|
endpoint: yield (0, prompts_1.input)({
|
|
97
97
|
message: "Endpoint",
|
|
98
98
|
required: true,
|
|
99
|
-
default:
|
|
99
|
+
default: applicationFromDB.endpoint
|
|
100
100
|
}),
|
|
101
101
|
speechToText: {
|
|
102
102
|
productRef: yield (0, prompts_1.select)({
|
|
103
103
|
message: "SST Vendor",
|
|
104
104
|
choices: [{ name: "Deepgram", value: "stt.deepgram" }],
|
|
105
|
-
default: (_a =
|
|
105
|
+
default: (_a = applicationFromDB.speechToText) === null || _a === void 0 ? void 0 : _a.productRef
|
|
106
106
|
}),
|
|
107
107
|
config: {
|
|
108
108
|
languageCode: yield (0, prompts_1.select)({
|
|
@@ -111,7 +111,7 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
111
111
|
{ name: "English", value: "en-US" },
|
|
112
112
|
{ name: "Spanish", value: "es-ES" }
|
|
113
113
|
],
|
|
114
|
-
default: (_b =
|
|
114
|
+
default: (_b = applicationFromDB.speechToText) === null || _b === void 0 ? void 0 : _b.config.languageCode
|
|
115
115
|
}),
|
|
116
116
|
model: yield (0, prompts_1.select)({
|
|
117
117
|
message: "STT Model",
|
|
@@ -123,26 +123,26 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
123
123
|
value: "nova-2-conversationalai"
|
|
124
124
|
}
|
|
125
125
|
],
|
|
126
|
-
default: (_c =
|
|
126
|
+
default: (_c = applicationFromDB.speechToText) === null || _c === void 0 ? void 0 : _c.config.model
|
|
127
127
|
})
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
130
|
textToSpeech: {
|
|
131
131
|
productRef: yield (0, prompts_1.select)({
|
|
132
|
-
message: "
|
|
132
|
+
message: "TTS Vendor",
|
|
133
133
|
choices: [
|
|
134
134
|
{ name: "Deepgram", value: "tts.deepgram" },
|
|
135
135
|
{ name: "ElevenLabs", value: "tts.elevenlabs" },
|
|
136
136
|
{ name: "Google", value: "tts.google" },
|
|
137
137
|
{ name: "Azure", value: "tts.azure" }
|
|
138
138
|
],
|
|
139
|
-
default: (_d =
|
|
139
|
+
default: (_d = applicationFromDB.textToSpeech) === null || _d === void 0 ? void 0 : _d.productRef
|
|
140
140
|
}),
|
|
141
141
|
config: {
|
|
142
142
|
voice: yield (0, prompts_1.input)({
|
|
143
143
|
message: "TTS Voice",
|
|
144
144
|
required: true,
|
|
145
|
-
default: (_e =
|
|
145
|
+
default: (_e = applicationFromDB.textToSpeech) === null || _e === void 0 ? void 0 : _e.config.voice
|
|
146
146
|
})
|
|
147
147
|
}
|
|
148
148
|
},
|
|
@@ -75,8 +75,8 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
75
75
|
const { args } = yield this.parse(Update);
|
|
76
76
|
const client = yield this.createSdkClient();
|
|
77
77
|
const secrets = new SDK.Secrets(client);
|
|
78
|
-
const
|
|
79
|
-
if (!
|
|
78
|
+
const secretFromDB = yield secrets.getSecret(args.ref);
|
|
79
|
+
if (!secretFromDB) {
|
|
80
80
|
this.error("Secret not found.");
|
|
81
81
|
}
|
|
82
82
|
this.log("This utility will help you update a Secret.");
|
|
@@ -85,7 +85,7 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
85
85
|
name: yield (0, prompts_1.input)({
|
|
86
86
|
message: "Name",
|
|
87
87
|
required: true,
|
|
88
|
-
default:
|
|
88
|
+
default: secretFromDB.name
|
|
89
89
|
}),
|
|
90
90
|
type: yield (0, prompts_1.password)({
|
|
91
91
|
message: "Secret"
|
|
@@ -69,21 +69,15 @@ const core_1 = require("@oclif/core");
|
|
|
69
69
|
const cliui_1 = __importDefault(require("cliui"));
|
|
70
70
|
const moment_1 = __importDefault(require("moment"));
|
|
71
71
|
const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
|
|
72
|
-
const config_1 = require("../../../config");
|
|
73
|
-
const constants_1 = require("../../../constants");
|
|
74
72
|
class Get extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
75
73
|
run() {
|
|
76
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
75
|
var _a, _b, _c, _d, _e, _f;
|
|
78
76
|
const { args } = yield this.parse(Get);
|
|
79
|
-
const
|
|
80
|
-
const currentWorkspace = workspaces.find((w) => w.active);
|
|
81
|
-
if (!currentWorkspace) {
|
|
82
|
-
this.error("No active workspace found.");
|
|
83
|
-
}
|
|
77
|
+
const { ref } = args;
|
|
84
78
|
const client = yield this.createSdkClient();
|
|
85
79
|
const numbers = new SDK.Numbers(client);
|
|
86
|
-
const response = yield numbers.getNumber(
|
|
80
|
+
const response = yield numbers.getNumber(ref);
|
|
87
81
|
const apps = new SDK.Applications(client);
|
|
88
82
|
let app;
|
|
89
83
|
try {
|
|
@@ -73,12 +73,6 @@ class LinkTwilioNumber extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
73
73
|
run() {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
const { flags } = yield this.parse(LinkTwilioNumber);
|
|
76
|
-
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
77
|
-
const currentWorkspace = workspaces.find((w) => w.active);
|
|
78
|
-
const accessKeyId = `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`;
|
|
79
|
-
if (!currentWorkspace) {
|
|
80
|
-
this.error("No active workspace found.");
|
|
81
|
-
}
|
|
82
76
|
const fonosterClient = yield this.createSdkClient();
|
|
83
77
|
const applications = new Fonoster.Applications(fonosterClient);
|
|
84
78
|
const appsList = (yield applications.listApplications({ pageSize: 1000 })).items.map((app) => ({
|
|
@@ -116,6 +110,8 @@ class LinkTwilioNumber extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
116
110
|
}
|
|
117
111
|
try {
|
|
118
112
|
const twilioClient = new twilio_1.Twilio(answers.twilioAccountSid, answers.twilioAuthToken);
|
|
113
|
+
const activeWorkspace = (0, config_1.getActiveWorkspace)((0, config_1.getConfig)(constants_1.CONFIG_FILE));
|
|
114
|
+
const accessKeyId = `WO${activeWorkspace.workspaceRef.replaceAll("-", "")}`;
|
|
119
115
|
yield (0, utils_1.linkTwilioNumberToApplication)(twilioClient, fonosterClient, {
|
|
120
116
|
phoneNumber: answers.number,
|
|
121
117
|
accessKeyId,
|
|
@@ -68,17 +68,10 @@ const SDK = __importStar(require("@fonoster/sdk"));
|
|
|
68
68
|
const core_1 = require("@oclif/core");
|
|
69
69
|
const cliui_1 = __importDefault(require("cliui"));
|
|
70
70
|
const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
|
|
71
|
-
const config_1 = require("../../../config");
|
|
72
|
-
const constants_1 = require("../../../constants");
|
|
73
71
|
class List extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
74
72
|
run() {
|
|
75
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
74
|
const { flags } = yield this.parse(List);
|
|
77
|
-
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
78
|
-
const currentWorkspace = workspaces.find((w) => w.active);
|
|
79
|
-
if (!currentWorkspace) {
|
|
80
|
-
this.error("No active workspace found.");
|
|
81
|
-
}
|
|
82
75
|
const client = yield this.createSdkClient();
|
|
83
76
|
const numbers = new SDK.Numbers(client);
|
|
84
77
|
const response = yield numbers.listNumbers({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
|
|
2
2
|
export default class Delete extends AuthenticatedCommand<typeof Delete> {
|
|
3
|
-
static readonly description = "remove a Trunk from the
|
|
3
|
+
static readonly description = "remove a Trunk from the active Workspace";
|
|
4
4
|
static readonly examples: string[];
|
|
5
5
|
static readonly args: {
|
|
6
6
|
ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
@@ -76,7 +76,7 @@ class Delete extends AuthenticatedCommand_1.AuthenticatedCommand {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
Delete.description = "remove a Trunk from the
|
|
79
|
+
Delete.description = "remove a Trunk from the active Workspace";
|
|
80
80
|
Delete.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
81
81
|
Delete.args = {
|
|
82
82
|
ref: core_1.Args.string({
|
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
/* eslint-disable import/no-unresolved */
|
|
13
16
|
/*
|
|
@@ -31,16 +34,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
31
34
|
const core_1 = require("@oclif/core");
|
|
32
35
|
const config_1 = require("../../config");
|
|
33
36
|
const constants_1 = require("../../constants");
|
|
34
|
-
|
|
37
|
+
const cliui_1 = __importDefault(require("cliui"));
|
|
38
|
+
class Active extends core_1.Command {
|
|
35
39
|
run() {
|
|
36
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
41
|
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
38
|
-
const
|
|
39
|
-
const { workspaceName, workspaceRef } =
|
|
40
|
-
|
|
42
|
+
const activeWorkspace = workspaces.find((w) => w.active === true);
|
|
43
|
+
const { workspaceName, workspaceRef, workspaceAccessKeyId, endpoint } = activeWorkspace;
|
|
44
|
+
const ui = (0, cliui_1.default)({ width: 200 });
|
|
45
|
+
ui.div("ACTIVE WORKSPACE\n" +
|
|
46
|
+
"------------------\n" +
|
|
47
|
+
`NAME: \t${workspaceName}\n` +
|
|
48
|
+
`REF: \t${workspaceRef}\n` +
|
|
49
|
+
`ACCESS KEY ID: \t${workspaceAccessKeyId}\n` +
|
|
50
|
+
`ENDPOINT: \t${endpoint}\n`);
|
|
51
|
+
this.log(ui.toString());
|
|
41
52
|
});
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
exports.default =
|
|
55
|
+
Active.description = "display the name of the active Workspace";
|
|
56
|
+
Active.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
57
|
+
exports.default = Active;
|
|
@@ -38,10 +38,10 @@ class Use extends core_1.Command {
|
|
|
38
38
|
const { args } = yield this.parse(Use);
|
|
39
39
|
const { ref } = args;
|
|
40
40
|
const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
|
|
41
|
-
const updatedWorkspaces = (0, config_1.
|
|
42
|
-
const
|
|
41
|
+
const updatedWorkspaces = (0, config_1.setActiveWorkspace)(ref, workspaces);
|
|
42
|
+
const activeWorkspace = (0, config_1.getActiveWorkspace)(updatedWorkspaces);
|
|
43
43
|
(0, saveConfig_1.saveConfig)(constants_1.CONFIG_FILE, updatedWorkspaces);
|
|
44
|
-
const { workspaceName, workspaceRef } =
|
|
44
|
+
const { workspaceName, workspaceRef } = activeWorkspace;
|
|
45
45
|
this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.getActiveWorkspace = getActiveWorkspace;
|
|
4
|
+
function getActiveWorkspace(workspaces) {
|
|
5
5
|
return workspaces.find((w) => w.active === true);
|
|
6
6
|
}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./addWorkspace";
|
|
2
2
|
export * from "./getConfig";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./getActiveWorkspace";
|
|
4
4
|
export * from "./removeWorkspace";
|
|
5
5
|
export * from "./saveConfig";
|
|
6
|
-
export * from "./
|
|
6
|
+
export * from "./setActiveWorkspace";
|
|
7
7
|
export * from "./types";
|
package/dist/config/index.js
CHANGED
|
@@ -34,8 +34,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
*/
|
|
35
35
|
__exportStar(require("./addWorkspace"), exports);
|
|
36
36
|
__exportStar(require("./getConfig"), exports);
|
|
37
|
-
__exportStar(require("./
|
|
37
|
+
__exportStar(require("./getActiveWorkspace"), exports);
|
|
38
38
|
__exportStar(require("./removeWorkspace"), exports);
|
|
39
39
|
__exportStar(require("./saveConfig"), exports);
|
|
40
|
-
__exportStar(require("./
|
|
40
|
+
__exportStar(require("./setActiveWorkspace"), exports);
|
|
41
41
|
__exportStar(require("./types"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.setActiveWorkspace = setActiveWorkspace;
|
|
4
|
+
function setActiveWorkspace(ref, workspaces) {
|
|
5
5
|
return workspaces.map((w) => {
|
|
6
6
|
if (w.workspaceRef === ref) {
|
|
7
7
|
return Object.assign(Object.assign({}, w), { active: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/ctl",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.49",
|
|
4
4
|
"description": "Fonoster Control Tool",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "3fdbcfdf8240218f371a03826ccf75175bee5610",
|
|
34
34
|
"bin": {
|
|
35
35
|
"fonoster": "./bin/run.js"
|
|
36
36
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"helpClass": "./dist/help"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@fonoster/sdk": "^0.7.
|
|
45
|
+
"@fonoster/sdk": "^0.7.49",
|
|
46
46
|
"@inquirer/prompts": "^7.1.0",
|
|
47
47
|
"@oclif/core": "^4.0.34",
|
|
48
48
|
"cliui": "^8.0.1",
|