@fonoster/ctl 0.7.47 → 0.7.48

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.
@@ -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 currentWorkspace = (0, config_1.getCurrentWorkspace)(workspaces);
74
- if (!currentWorkspace) {
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: currentWorkspace.endpoint,
80
- accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
79
+ endpoint: activeWorkspace.endpoint,
80
+ accessKeyId: `WO${activeWorkspace.workspaceRef.replaceAll("-", "")}`,
81
81
  allowInsecure: this.flags.insecure
82
82
  });
83
- yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
83
+ yield client.loginWithApiKey(activeWorkspace.accessKeyId, activeWorkspace.accessKeySecret);
84
84
  return client;
85
85
  }
86
86
  catch (error) {
@@ -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 currentApplication = yield applications.getApplication(args.ref);
80
- if (!currentApplication) {
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: currentApplication.name
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: currentApplication.type
94
+ default: applicationFromDB.type
95
95
  }),
96
96
  endpoint: yield (0, prompts_1.input)({
97
97
  message: "Endpoint",
98
98
  required: true,
99
- default: currentApplication.endpoint
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 = currentApplication.speechToText) === null || _a === void 0 ? void 0 : _a.productRef
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 = currentApplication.speechToText) === null || _b === void 0 ? void 0 : _b.config.languageCode
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,7 +123,7 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
123
123
  value: "nova-2-conversationalai"
124
124
  }
125
125
  ],
126
- default: (_c = currentApplication.speechToText) === null || _c === void 0 ? void 0 : _c.config.model
126
+ default: (_c = applicationFromDB.speechToText) === null || _c === void 0 ? void 0 : _c.config.model
127
127
  })
128
128
  }
129
129
  },
@@ -136,13 +136,13 @@ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
136
136
  { name: "Google", value: "tts.google" },
137
137
  { name: "Azure", value: "tts.azure" }
138
138
  ],
139
- default: (_d = currentApplication.textToSpeech) === null || _d === void 0 ? void 0 : _d.productRef
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 = currentApplication.textToSpeech) === null || _e === void 0 ? void 0 : _e.config.voice
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 currentSecret = yield secrets.getSecret(args.ref);
79
- if (!currentSecret) {
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: currentSecret.name
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 workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
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(args.ref);
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 current Workspace";
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 current Workspace";
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({
@@ -1,5 +1,5 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class Current extends Command {
2
+ export default class Active extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  run(): Promise<void>;
@@ -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
- class Current extends core_1.Command {
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 currentWorkspace = workspaces.find((w) => w.active === true);
39
- const { workspaceName, workspaceRef } = currentWorkspace;
40
- this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
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
- Current.description = "display the name of the active Workspace";
45
- Current.examples = ["<%= config.bin %> <%= command.id %>"];
46
- exports.default = Current;
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.setCurrentWorkspace)(ref, workspaces);
42
- const currentWorkspace = (0, config_1.getCurrentWorkspace)(updatedWorkspaces);
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 } = currentWorkspace;
44
+ const { workspaceName, workspaceRef } = activeWorkspace;
45
45
  this.log(`Current Workspace: ${workspaceName} (${workspaceRef})`);
46
46
  });
47
47
  }
@@ -0,0 +1,3 @@
1
+ import { WorkspaceConfig } from "./types";
2
+ declare function getActiveWorkspace(workspaces: WorkspaceConfig[]): WorkspaceConfig;
3
+ export { getActiveWorkspace };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCurrentWorkspace = getCurrentWorkspace;
4
- function getCurrentWorkspace(workspaces) {
3
+ exports.getActiveWorkspace = getActiveWorkspace;
4
+ function getActiveWorkspace(workspaces) {
5
5
  return workspaces.find((w) => w.active === true);
6
6
  }
@@ -1,7 +1,7 @@
1
1
  export * from "./addWorkspace";
2
2
  export * from "./getConfig";
3
- export * from "./getCurrentWorkspace";
3
+ export * from "./getActiveWorkspace";
4
4
  export * from "./removeWorkspace";
5
5
  export * from "./saveConfig";
6
- export * from "./setCurrentWorkspace";
6
+ export * from "./setActiveWorkspace";
7
7
  export * from "./types";
@@ -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("./getCurrentWorkspace"), exports);
37
+ __exportStar(require("./getActiveWorkspace"), exports);
38
38
  __exportStar(require("./removeWorkspace"), exports);
39
39
  __exportStar(require("./saveConfig"), exports);
40
- __exportStar(require("./setCurrentWorkspace"), exports);
40
+ __exportStar(require("./setActiveWorkspace"), exports);
41
41
  __exportStar(require("./types"), exports);
@@ -0,0 +1,3 @@
1
+ import { WorkspaceConfig } from "./types";
2
+ declare function setActiveWorkspace(ref: string, workspaces: WorkspaceConfig[]): WorkspaceConfig[];
3
+ export { setActiveWorkspace };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setCurrentWorkspace = setCurrentWorkspace;
4
- function setCurrentWorkspace(ref, workspaces) {
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.47",
3
+ "version": "0.7.48",
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": "6d3f97e9f11d0f526c013b7d210ef482787e799e",
33
+ "gitHead": "4fe2fc66e6a3bd25095f00fdbe539b757ab5edbb",
34
34
  "bin": {
35
35
  "fonoster": "./bin/run.js"
36
36
  },
@@ -1,3 +0,0 @@
1
- import { WorkspaceConfig } from "./types";
2
- declare function getCurrentWorkspace(workspaces: WorkspaceConfig[]): WorkspaceConfig;
3
- export { getCurrentWorkspace };
@@ -1,3 +0,0 @@
1
- import { WorkspaceConfig } from "./types";
2
- declare function setCurrentWorkspace(ref: string, workspaces: WorkspaceConfig[]): WorkspaceConfig[];
3
- export { setCurrentWorkspace };