@fonoster/ctl 0.7.39 → 0.7.41

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.
Files changed (58) hide show
  1. package/dist/BaseCommand.d.ts +15 -0
  2. package/dist/BaseCommand.js +80 -0
  3. package/dist/Help.d.ts +6 -0
  4. package/dist/Help.js +52 -0
  5. package/dist/commands/applications/create.d.ts +6 -0
  6. package/dist/commands/applications/create.js +164 -0
  7. package/dist/commands/applications/delete.d.ts +9 -0
  8. package/dist/commands/applications/delete.js +99 -0
  9. package/dist/commands/applications/get.d.ts +9 -0
  10. package/dist/commands/applications/get.js +120 -0
  11. package/dist/commands/applications/list.d.ts +9 -0
  12. package/dist/commands/applications/list.js +112 -0
  13. package/dist/commands/applications/update.d.ts +9 -0
  14. package/dist/commands/applications/update.js +187 -0
  15. package/dist/commands/{workspace/login.d.ts → bug.d.ts} +1 -1
  16. package/dist/commands/bug.js +42 -0
  17. package/dist/commands/feedback.d.ts +6 -0
  18. package/dist/commands/feedback.js +45 -0
  19. package/dist/commands/numbers/get.d.ts +9 -0
  20. package/dist/commands/numbers/get.js +125 -0
  21. package/dist/commands/numbers/linkTwilioNumber.d.ts +10 -0
  22. package/dist/commands/numbers/linkTwilioNumber.js +155 -0
  23. package/dist/commands/numbers/list.d.ts +9 -0
  24. package/dist/commands/numbers/list.js +116 -0
  25. package/dist/commands/workspaces/current.d.ts +6 -0
  26. package/dist/commands/workspaces/current.js +46 -0
  27. package/dist/commands/workspaces/list.d.ts +6 -0
  28. package/dist/commands/workspaces/list.js +53 -0
  29. package/dist/commands/workspaces/login.d.ts +8 -0
  30. package/dist/commands/workspaces/login.js +145 -0
  31. package/dist/commands/workspaces/logout.d.ts +9 -0
  32. package/dist/commands/{workspace/login.js → workspaces/logout.js} +13 -39
  33. package/dist/commands/workspaces/use.d.ts +9 -0
  34. package/dist/commands/workspaces/use.js +57 -0
  35. package/dist/config/addWorkspace.js +6 -1
  36. package/dist/config/validations.d.ts +3 -0
  37. package/dist/config/validations.js +3 -0
  38. package/dist/constants.d.ts +3 -0
  39. package/dist/constants.js +4 -1
  40. package/dist/utils/assignTwilioNumberToTrunk.d.ts +3 -0
  41. package/dist/utils/assignTwilioNumberToTrunk.js +33 -0
  42. package/dist/utils/createTwilioTrunk.d.ts +4 -0
  43. package/dist/utils/createTwilioTrunk.js +54 -0
  44. package/dist/utils/getFonosterNumberByTelUrl.d.ts +4 -0
  45. package/dist/utils/getFonosterNumberByTelUrl.js +76 -0
  46. package/dist/utils/getFonosterTrunkByInboundUri.d.ts +4 -0
  47. package/dist/utils/getFonosterTrunkByInboundUri.js +76 -0
  48. package/dist/utils/getTwilioNumber.d.ts +4 -0
  49. package/dist/utils/getTwilioNumber.js +23 -0
  50. package/dist/utils/getTwilioTrunk.d.ts +4 -0
  51. package/dist/utils/getTwilioTrunk.js +23 -0
  52. package/dist/utils/index.d.ts +8 -0
  53. package/dist/utils/index.js +42 -0
  54. package/dist/utils/linkTwilioNumberToApplication.d.ts +5 -0
  55. package/dist/utils/linkTwilioNumberToApplication.js +128 -0
  56. package/dist/utils/types.d.ts +14 -0
  57. package/dist/utils/types.js +2 -0
  58. package/package.json +15 -7
@@ -0,0 +1,15 @@
1
+ import { Command, Interfaces } from "@oclif/core";
2
+ export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
3
+ export declare abstract class BaseCommand<T extends typeof Command> extends Command {
4
+ static baseFlags: {
5
+ insecure: Interfaces.BooleanFlag<boolean>;
6
+ };
7
+ protected flags: Flags<T>;
8
+ protected args: Args<T>;
9
+ init(): Promise<void>;
10
+ protected catch(err: Error & {
11
+ exitCode?: number;
12
+ }): Promise<any>;
13
+ protected finally(_: Error | undefined): Promise<any>;
14
+ }
15
+ export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)["baseFlags"] & T["flags"]>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseCommand = void 0;
13
+ /* eslint-disable import/no-unresolved */
14
+ /*
15
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
16
+ * http://github.com/fonoster/fonoster
17
+ *
18
+ * This file is part of Fonoster
19
+ *
20
+ * Licensed under the MIT License (the "License");
21
+ * you may not use this file except in compliance with
22
+ * the License. You may obtain a copy of the License at
23
+ *
24
+ * https://opensource.org/licenses/MIT
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */
32
+ const core_1 = require("@oclif/core");
33
+ class BaseCommand extends core_1.Command {
34
+ init() {
35
+ const _super = Object.create(null, {
36
+ init: { get: () => super.init },
37
+ ctor: { get: () => super.ctor }
38
+ });
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ yield _super.init.call(this);
41
+ const { args, flags } = yield this.parse({
42
+ flags: this.ctor.flags,
43
+ baseFlags: _super.ctor.baseFlags,
44
+ enableJsonFlag: this.ctor.enableJsonFlag,
45
+ args: this.ctor.args,
46
+ strict: this.ctor.strict
47
+ });
48
+ this.flags = flags;
49
+ this.args = args;
50
+ });
51
+ }
52
+ catch(err) {
53
+ const _super = Object.create(null, {
54
+ catch: { get: () => super.catch }
55
+ });
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ // add any custom logic to handle errors from the command
58
+ // or simply return the parent class error handling
59
+ return _super.catch.call(this, err);
60
+ });
61
+ }
62
+ finally(_) {
63
+ const _super = Object.create(null, {
64
+ finally: { get: () => super.finally }
65
+ });
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ // called after run and catch regardless of whether or not the command errored
68
+ return _super.finally.call(this, _);
69
+ });
70
+ }
71
+ }
72
+ exports.BaseCommand = BaseCommand;
73
+ // define flags that can be inherited by any command that extends BaseCommand
74
+ BaseCommand.baseFlags = {
75
+ insecure: core_1.Flags.boolean({
76
+ char: "i",
77
+ description: "allow connections to a server without TLS enabled",
78
+ default: false
79
+ })
80
+ };
package/dist/Help.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Help } from "@oclif/core";
2
+ export default class CustomHelp extends Help {
3
+ protected showRootHelp(): Promise<void>;
4
+ private showLogo;
5
+ private get customCommands();
6
+ }
package/dist/Help.js ADDED
@@ -0,0 +1,52 @@
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) 2024 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
+ // eslint-disable-next-line import/no-unresolved
25
+ const core_1 = require("@oclif/core");
26
+ const figlet_1 = __importDefault(require("figlet"));
27
+ class CustomHelp extends core_1.Help {
28
+ showRootHelp() {
29
+ this.showLogo();
30
+ this.log(this.formatRoot());
31
+ this.log("");
32
+ this.log(this.formatCommands(this.customCommands));
33
+ this.log("");
34
+ return Promise.resolve();
35
+ }
36
+ showLogo() {
37
+ this.log("\x1b[32m");
38
+ this.log(figlet_1.default.textSync("Fonoster", {
39
+ horizontalLayout: "default",
40
+ verticalLayout: "default",
41
+ width: 60,
42
+ whitespaceBreak: true
43
+ }));
44
+ this.log("\x1b[0m");
45
+ }
46
+ get customCommands() {
47
+ return this.sortedCommands
48
+ .filter((c) => c.id)
49
+ .sort((a, b) => (a.id.includes(":") ? 1 : b.id.includes(":") ? -1 : 0));
50
+ }
51
+ }
52
+ exports.default = CustomHelp;
@@ -0,0 +1,6 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class Create extends BaseCommand<typeof Create> {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ /* eslint-disable import/no-unresolved */
46
+ /*
47
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
48
+ * http://github.com/fonoster/fonoster
49
+ *
50
+ * This file is part of Fonoster
51
+ *
52
+ * Licensed under the MIT License (the "License");
53
+ * you may not use this file except in compliance with
54
+ * the License. You may obtain a copy of the License at
55
+ *
56
+ * https://opensource.org/licenses/MIT
57
+ *
58
+ * Unless required by applicable law or agreed to in writing, software
59
+ * distributed under the License is distributed on an "AS IS" BASIS,
60
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
+ * See the License for the specific language governing permissions and
62
+ * limitations under the License.
63
+ */
64
+ const SDK = __importStar(require("@fonoster/sdk"));
65
+ const prompts_1 = require("@inquirer/prompts");
66
+ const BaseCommand_1 = require("../../BaseCommand");
67
+ const config_1 = require("../../config");
68
+ const constants_1 = require("../../constants");
69
+ class Create extends BaseCommand_1.BaseCommand {
70
+ run() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const { flags } = yield this.parse(Create);
73
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
74
+ const currentWorkspace = workspaces.find((w) => w.active);
75
+ if (!currentWorkspace) {
76
+ this.error("No active workspace found.");
77
+ }
78
+ this.log("This utility will help you create an Application.");
79
+ this.log("Press ^C at any time to quit.");
80
+ const answers = {
81
+ name: yield (0, prompts_1.input)({
82
+ message: "Name",
83
+ required: true
84
+ }),
85
+ type: yield (0, prompts_1.select)({
86
+ message: "Type",
87
+ choices: [{ name: "External", value: "External" }]
88
+ }),
89
+ endpoint: yield (0, prompts_1.input)({
90
+ message: "Endpoint",
91
+ required: true
92
+ }),
93
+ speechToText: {
94
+ productRef: yield (0, prompts_1.select)({
95
+ message: "SST Vendor",
96
+ choices: [{ name: "Deepgram", value: "stt.deepgram" }]
97
+ }),
98
+ config: {
99
+ languageCode: yield (0, prompts_1.select)({
100
+ message: "STT Language",
101
+ choices: [
102
+ { name: "English", value: "en-US" },
103
+ { name: "Spanish", value: "es-ES" }
104
+ ]
105
+ }),
106
+ model: yield (0, prompts_1.select)({
107
+ message: "STT Model",
108
+ choices: [
109
+ { name: "Nova 2", value: "nova-2" },
110
+ { name: "Nova 2 Phone Call", value: "nova-2-phonecall" },
111
+ {
112
+ name: "Nova 2 Conversational AI",
113
+ value: "nova-2-conversationalai"
114
+ }
115
+ ],
116
+ default: "nova-2"
117
+ })
118
+ }
119
+ },
120
+ textToSpeech: {
121
+ productRef: yield (0, prompts_1.select)({
122
+ message: "TTV Vendor",
123
+ choices: [
124
+ { name: "Deepgram", value: "tts.deepgram" },
125
+ { name: "ElevenLabs", value: "tts.elevenlabs" },
126
+ { name: "Google", value: "tts.google" },
127
+ { name: "Azure", value: "tts.azure" }
128
+ ]
129
+ }),
130
+ config: {
131
+ voice: yield (0, prompts_1.input)({
132
+ message: "TTS Voice",
133
+ required: true
134
+ })
135
+ }
136
+ },
137
+ confirm: yield (0, prompts_1.confirm)({
138
+ message: "Ready?"
139
+ })
140
+ };
141
+ if (!answers.confirm) {
142
+ this.log("Aborted!");
143
+ return;
144
+ }
145
+ try {
146
+ const client = new SDK.Client({
147
+ endpoint: currentWorkspace.endpoint,
148
+ accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
149
+ allowInsecure: flags.insecure
150
+ });
151
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
152
+ const applications = new SDK.Applications(client);
153
+ yield applications.createApplication(answers);
154
+ this.log("Done!");
155
+ }
156
+ catch (e) {
157
+ this.error(e);
158
+ }
159
+ });
160
+ }
161
+ }
162
+ Create.description = "create a new Application";
163
+ Create.examples = ["<%= config.bin %> <%= command.id %>"];
164
+ exports.default = Create;
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class Delete extends BaseCommand<typeof Delete> {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ /* eslint-disable import/no-unresolved */
46
+ /*
47
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
48
+ * http://github.com/fonoster/fonoster
49
+ *
50
+ * This file is part of Fonoster
51
+ *
52
+ * Licensed under the MIT License (the "License");
53
+ * you may not use this file except in compliance with
54
+ * the License. You may obtain a copy of the License at
55
+ *
56
+ * https://opensource.org/licenses/MIT
57
+ *
58
+ * Unless required by applicable law or agreed to in writing, software
59
+ * distributed under the License is distributed on an "AS IS" BASIS,
60
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61
+ * See the License for the specific language governing permissions and
62
+ * limitations under the License.
63
+ */
64
+ const SDK = __importStar(require("@fonoster/sdk"));
65
+ const core_1 = require("@oclif/core");
66
+ const BaseCommand_1 = require("../../BaseCommand");
67
+ const config_1 = require("../../config");
68
+ const constants_1 = require("../../constants");
69
+ class Delete extends BaseCommand_1.BaseCommand {
70
+ run() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const { args, flags } = yield this.parse(Delete);
73
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
74
+ const currentWorkspace = workspaces.find((w) => w.active);
75
+ if (!currentWorkspace) {
76
+ this.error("No active workspace found.");
77
+ }
78
+ if (!args.ref) {
79
+ this.error("Missing Application reference");
80
+ return;
81
+ }
82
+ const client = new SDK.Client({
83
+ endpoint: currentWorkspace.endpoint,
84
+ accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
85
+ allowInsecure: flags.insecure
86
+ });
87
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
88
+ const applications = new SDK.Applications(client);
89
+ yield applications.deleteApplication(args.ref);
90
+ this.log("Done!");
91
+ });
92
+ }
93
+ }
94
+ Delete.description = "remove an Application from the system";
95
+ Delete.examples = ["<%= config.bin %> <%= command.id %>"];
96
+ Delete.args = {
97
+ ref: core_1.Args.string({ description: "the Application to delete" })
98
+ };
99
+ exports.default = Delete;
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class Get extends BaseCommand<typeof Get> {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ /* eslint-disable import/no-unresolved */
49
+ /*
50
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
51
+ * http://github.com/fonoster/fonoster
52
+ *
53
+ * This file is part of Fonoster
54
+ *
55
+ * Licensed under the MIT License (the "License");
56
+ * you may not use this file except in compliance with
57
+ * the License. You may obtain a copy of the License at
58
+ *
59
+ * https://opensource.org/licenses/MIT
60
+ *
61
+ * Unless required by applicable law or agreed to in writing, software
62
+ * distributed under the License is distributed on an "AS IS" BASIS,
63
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64
+ * See the License for the specific language governing permissions and
65
+ * limitations under the License.
66
+ */
67
+ const SDK = __importStar(require("@fonoster/sdk"));
68
+ const core_1 = require("@oclif/core");
69
+ const cliui_1 = __importDefault(require("cliui"));
70
+ const moment_1 = __importDefault(require("moment"));
71
+ const BaseCommand_1 = require("../../BaseCommand");
72
+ const config_1 = require("../../config");
73
+ const constants_1 = require("../../constants");
74
+ class Get extends BaseCommand_1.BaseCommand {
75
+ run() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ var _a, _b, _c, _d;
78
+ const { flags } = yield this.parse(Get);
79
+ const { args } = yield this.parse(Get);
80
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
81
+ const currentWorkspace = workspaces.find((w) => w.active);
82
+ if (!currentWorkspace) {
83
+ this.error("No active workspace found.");
84
+ }
85
+ const client = new SDK.Client({
86
+ endpoint: currentWorkspace.endpoint,
87
+ accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
88
+ allowInsecure: flags.insecure
89
+ });
90
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
91
+ const applications = new SDK.Applications(client);
92
+ const response = yield applications.getApplication(args.ref);
93
+ const ui = (0, cliui_1.default)({ width: 200 });
94
+ // STT or none of productRef is undefined
95
+ const stt = ((_a = response.speechToText) === null || _a === void 0 ? void 0 : _a.productRef)
96
+ ? (_b = response.speechToText) === null || _b === void 0 ? void 0 : _b.productRef.replace("stt.", "")
97
+ : "none";
98
+ const tts = ((_c = response.textToSpeech) === null || _c === void 0 ? void 0 : _c.productRef)
99
+ ? (_d = response.textToSpeech) === null || _d === void 0 ? void 0 : _d.productRef.replace("tts.", "")
100
+ : "none";
101
+ ui.div("APPLICATION DETAILS\n" +
102
+ "------------------\n" +
103
+ `NAME: \t${response.name}\n` +
104
+ `REF: \t${response.ref}\n` +
105
+ `STT: \t${stt}\n` +
106
+ `TTS: \t${tts}\n` +
107
+ `TYPE: \t${response.type}\n` +
108
+ `ENDPOINT: \t${response.endpoint}\n` +
109
+ `CREATED: \t${(0, moment_1.default)(response.createdAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
110
+ `UPDATED: \t${(0, moment_1.default)(response.updatedAt).format("YYYY-MM-DD HH:mm:ss")}`);
111
+ this.log(ui.toString());
112
+ });
113
+ }
114
+ }
115
+ Get.description = "get an Application by reference";
116
+ Get.examples = ["<%= config.bin %> <%= command.id %>"];
117
+ Get.args = {
118
+ ref: core_1.Args.string({ description: "The Application to show details about" })
119
+ };
120
+ exports.default = Get;
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class List extends BaseCommand<typeof List> {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "page-size": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }