@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,112 @@
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 BaseCommand_1 = require("../../BaseCommand");
71
+ const config_1 = require("../../config");
72
+ const constants_1 = require("../../constants");
73
+ class List extends BaseCommand_1.BaseCommand {
74
+ run() {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ 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
+ 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
+ const response = yield applications.listApplications({
90
+ pageSize: parseInt(flags["page-size"]),
91
+ pageToken: ""
92
+ });
93
+ const ui = (0, cliui_1.default)({ width: 170 });
94
+ ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "NAME", padding: [0, 0, 0, 0], width: 30 }, { text: "TYPE", padding: [0, 0, 0, 0], width: 10 }, { text: "ENDPOINT", padding: [0, 0, 0, 0] });
95
+ response.items.forEach((application) => {
96
+ ui.div({ text: application.ref, padding: [0, 0, 0, 0], width: 40 }, { text: application.name, padding: [0, 0, 0, 0], width: 30 }, { text: application.type, padding: [0, 0, 0, 0], width: 10 }, { text: application.endpoint, padding: [0, 0, 0, 0] });
97
+ });
98
+ this.log(ui.toString());
99
+ });
100
+ }
101
+ }
102
+ List.description = "list all existing Applications";
103
+ List.examples = ["<%= config.bin %> <%= command.id %>"];
104
+ List.flags = {
105
+ "page-size": core_1.Flags.string({
106
+ char: "s",
107
+ description: "the number of items to show",
108
+ default: "1000",
109
+ required: false
110
+ })
111
+ };
112
+ exports.default = List;
@@ -0,0 +1,9 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class Update extends BaseCommand<typeof Update> {
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,187 @@
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 core_1 = require("@oclif/core");
67
+ const BaseCommand_1 = require("../../BaseCommand");
68
+ const config_1 = require("../../config");
69
+ const constants_1 = require("../../constants");
70
+ class Update extends BaseCommand_1.BaseCommand {
71
+ run() {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ var _a, _b, _c, _d, _e;
74
+ const { flags, args } = yield this.parse(Update);
75
+ const workspaces = (0, config_1.getConfig)(constants_1.CONFIG_FILE);
76
+ const currentWorkspace = workspaces.find((w) => w.active);
77
+ if (!currentWorkspace) {
78
+ this.error("No active workspace found.");
79
+ }
80
+ const client = new SDK.Client({
81
+ endpoint: currentWorkspace.endpoint,
82
+ accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
83
+ allowInsecure: flags.insecure
84
+ });
85
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
86
+ const applications = new SDK.Applications(client);
87
+ const currentApplication = yield applications.getApplication(args.ref);
88
+ if (!currentApplication) {
89
+ this.error("Application not found.");
90
+ }
91
+ this.log("This utility will help you create an Application.");
92
+ this.log("Press ^C at any time to quit.");
93
+ const answers = {
94
+ name: yield (0, prompts_1.input)({
95
+ message: "Name",
96
+ required: true,
97
+ default: currentApplication.name
98
+ }),
99
+ type: yield (0, prompts_1.select)({
100
+ message: "Type",
101
+ choices: [{ name: "External", value: "External" }],
102
+ default: currentApplication.type
103
+ }),
104
+ endpoint: yield (0, prompts_1.input)({
105
+ message: "Endpoint",
106
+ required: true,
107
+ default: currentApplication.endpoint
108
+ }),
109
+ speechToText: {
110
+ productRef: yield (0, prompts_1.select)({
111
+ message: "SST Vendor",
112
+ choices: [{ name: "Deepgram", value: "stt.deepgram" }],
113
+ default: (_a = currentApplication.speechToText) === null || _a === void 0 ? void 0 : _a.productRef
114
+ }),
115
+ config: {
116
+ languageCode: yield (0, prompts_1.select)({
117
+ message: "STT Language",
118
+ choices: [
119
+ { name: "English", value: "en-US" },
120
+ { name: "Spanish", value: "es-ES" }
121
+ ],
122
+ default: (_b = currentApplication.speechToText) === null || _b === void 0 ? void 0 : _b.config.languageCode
123
+ }),
124
+ model: yield (0, prompts_1.select)({
125
+ message: "STT Model",
126
+ choices: [
127
+ { name: "Nova 2", value: "nova-2" },
128
+ { name: "Nova 2 Phone Call", value: "nova-2-phonecall" },
129
+ {
130
+ name: "Nova 2 Conversational AI",
131
+ value: "nova-2-conversationalai"
132
+ }
133
+ ],
134
+ default: (_c = currentApplication.speechToText) === null || _c === void 0 ? void 0 : _c.config.model
135
+ })
136
+ }
137
+ },
138
+ textToSpeech: {
139
+ productRef: yield (0, prompts_1.select)({
140
+ message: "TTV Vendor",
141
+ choices: [
142
+ { name: "Deepgram", value: "tts.deepgram" },
143
+ { name: "ElevenLabs", value: "tts.elevenlabs" },
144
+ { name: "Google", value: "tts.google" },
145
+ { name: "Azure", value: "tts.azure" }
146
+ ],
147
+ default: (_d = currentApplication.textToSpeech) === null || _d === void 0 ? void 0 : _d.productRef
148
+ }),
149
+ config: {
150
+ voice: yield (0, prompts_1.input)({
151
+ message: "TTS Voice",
152
+ required: true,
153
+ default: (_e = currentApplication.textToSpeech) === null || _e === void 0 ? void 0 : _e.config.voice
154
+ })
155
+ }
156
+ },
157
+ confirm: yield (0, prompts_1.confirm)({
158
+ message: "Ready?"
159
+ })
160
+ };
161
+ if (!answers.confirm) {
162
+ this.log("Aborted!");
163
+ return;
164
+ }
165
+ try {
166
+ const client = new SDK.Client({
167
+ endpoint: currentWorkspace.endpoint,
168
+ accessKeyId: `WO${currentWorkspace.workspaceRef.replaceAll("-", "")}`,
169
+ allowInsecure: flags.insecure
170
+ });
171
+ yield client.loginWithApiKey(currentWorkspace.accessKeyId, currentWorkspace.accessKeySecret);
172
+ const applications = new SDK.Applications(client);
173
+ yield applications.updateApplication(Object.assign({ ref: args.ref }, answers));
174
+ this.log("Done!");
175
+ }
176
+ catch (e) {
177
+ this.error(e);
178
+ }
179
+ });
180
+ }
181
+ }
182
+ Update.description = "update an existing Application";
183
+ Update.examples = ["<%= config.bin %> <%= command.id %>"];
184
+ Update.args = {
185
+ ref: core_1.Args.string({ description: "the Application to update" })
186
+ };
187
+ exports.default = Update;
@@ -1,5 +1,5 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class AuthLogin extends Command {
2
+ export default class Bug extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  run(): Promise<void>;
@@ -0,0 +1,42 @@
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
+ /* eslint-disable import/no-unresolved */
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const core_1 = require("@oclif/core");
32
+ class Bug extends core_1.Command {
33
+ run() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const link = " https://github.com/fonoster/fonoster/issues/new?assignees=&labels=bug&projects=&template=bug_report.yaml&title=%5BBUG%5D%3A+";
36
+ this.log(`Please report bugs to the link below:\n${link}`);
37
+ });
38
+ }
39
+ }
40
+ Bug.description = "start a bug report 🐞";
41
+ Bug.examples = ["<%= config.bin %> <%= command.id %>"];
42
+ exports.default = Bug;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Feedback extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,45 @@
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
+ /* eslint-disable import/no-unresolved */
13
+ /*
14
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
+ * http://github.com/fonoster/fonoster
16
+ *
17
+ * This file is part of Fonoster
18
+ *
19
+ * Licensed under the MIT License (the "License");
20
+ * you may not use this file except in compliance with
21
+ * the License. You may obtain a copy of the License at
22
+ *
23
+ * https://opensource.org/licenses/MIT
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ const core_1 = require("@oclif/core");
32
+ class Feedback extends core_1.Command {
33
+ run() {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const link = " https://docs.google.com/forms/d/e/1FAIpQLSd1G2ahRYqkbksOvz7XhNHfSLepUh3KzRHsXh2HXfZr68nhtQ/viewform?vc=0&c=0&w=1&flr=0";
36
+ this.log(`Please let us know how we're doing by filling out the form below:\n${link}`);
37
+ });
38
+ }
39
+ }
40
+ Feedback.description = `let us know how we're doing
41
+ ...
42
+ Help us improve by providing some feedback
43
+ `;
44
+ Feedback.examples = ["<%= config.bin %> <%= command.id %>"];
45
+ exports.default = Feedback;
@@ -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,125 @@
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, _e, _f;
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 numbers = new SDK.Numbers(client);
92
+ const response = yield numbers.getNumber(args.ref);
93
+ const apps = new SDK.Applications(client);
94
+ let app;
95
+ try {
96
+ app = yield apps.getApplication(response.appRef);
97
+ }
98
+ catch (e) {
99
+ // You can only try
100
+ }
101
+ const ui = (0, cliui_1.default)({ width: 200 });
102
+ ui.div("NUMBERS DETAILS\n" +
103
+ "------------------\n" +
104
+ `NAME: \t${response.name}\n` +
105
+ `REF: \t${response.ref}\n` +
106
+ `TEL URL: \t${response.telUrl}\n` +
107
+ `APP: \t${(_a = app === null || app === void 0 ? void 0 : app.name) !== null && _a !== void 0 ? _a : ""}\n` +
108
+ `APP REF: \t${(_b = app === null || app === void 0 ? void 0 : app.ref) !== null && _b !== void 0 ? _b : ""}\n` +
109
+ `CITY: \t${response.city}\n` +
110
+ `TRUNK NAME: \t${(_d = (_c = response.trunk) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : ""}\n` +
111
+ `TRUNK REF: \t${(_f = (_e = response.trunk) === null || _e === void 0 ? void 0 : _e.ref) !== null && _f !== void 0 ? _f : ""}\n` +
112
+ `COUNTRY ISO CODE: \t${response.countryIsoCode}\n` +
113
+ `COUNTRY: \t${response.country}\n` +
114
+ `CREATED: \t${(0, moment_1.default)(response.createdAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
115
+ `UPDATED: \t${(0, moment_1.default)(response.updatedAt).format("YYYY-MM-DD HH:mm:ss")}`);
116
+ this.log(ui.toString());
117
+ });
118
+ }
119
+ }
120
+ Get.description = "get an Number by reference";
121
+ Get.examples = ["<%= config.bin %> <%= command.id %>"];
122
+ Get.args = {
123
+ ref: core_1.Args.string({ description: "the Number to show details about" })
124
+ };
125
+ exports.default = Get;
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from "../../BaseCommand";
2
+ export default class LinkTwilioNumber extends BaseCommand<typeof LinkTwilioNumber> {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ "outbound-uri-base": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ "access-control-list": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ };
9
+ run(): Promise<void>;
10
+ }