@fonoster/ctl 0.7.44 → 0.7.46

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 (163) hide show
  1. package/README.md +1 -1
  2. package/bin/run.js +0 -18
  3. package/dist/AuthenticatedCommand.d.ts +6 -0
  4. package/dist/AuthenticatedCommand.js +92 -0
  5. package/dist/BaseCommand.d.ts +15 -0
  6. package/dist/BaseCommand.js +80 -0
  7. package/dist/Help.d.ts +6 -0
  8. package/dist/Help.js +52 -0
  9. package/dist/commands/apikeys/create.d.ts +10 -0
  10. package/dist/commands/apikeys/create.js +99 -0
  11. package/dist/commands/apikeys/delete.d.ts +9 -0
  12. package/dist/commands/apikeys/delete.js +87 -0
  13. package/dist/commands/apikeys/list.d.ts +9 -0
  14. package/dist/commands/apikeys/list.js +105 -0
  15. package/dist/commands/apikeys/regenerate.d.ts +9 -0
  16. package/dist/commands/apikeys/regenerate.js +91 -0
  17. package/dist/commands/applications/create.d.ts +6 -0
  18. package/dist/commands/applications/create.js +155 -0
  19. package/dist/commands/applications/delete.d.ts +9 -0
  20. package/dist/commands/applications/delete.js +87 -0
  21. package/dist/commands/applications/get.d.ts +9 -0
  22. package/dist/commands/applications/get.js +107 -0
  23. package/dist/commands/applications/list.d.ts +9 -0
  24. package/dist/commands/applications/list.js +99 -0
  25. package/dist/commands/applications/update.d.ts +9 -0
  26. package/dist/commands/applications/update.js +172 -0
  27. package/dist/commands/bug.d.ts +6 -0
  28. package/dist/commands/bug.js +42 -0
  29. package/dist/commands/feedback.d.ts +6 -0
  30. package/dist/commands/feedback.js +45 -0
  31. package/dist/commands/secrets/create.d.ts +6 -0
  32. package/dist/commands/secrets/create.js +106 -0
  33. package/dist/commands/secrets/delete.d.ts +9 -0
  34. package/dist/commands/secrets/delete.js +87 -0
  35. package/dist/commands/secrets/get.d.ts +9 -0
  36. package/dist/commands/secrets/get.js +95 -0
  37. package/dist/commands/secrets/list.d.ts +9 -0
  38. package/dist/commands/secrets/list.js +99 -0
  39. package/dist/commands/secrets/update.d.ts +9 -0
  40. package/dist/commands/secrets/update.js +116 -0
  41. package/dist/commands/sipnet/acls/create.d.ts +6 -0
  42. package/dist/commands/sipnet/acls/create.js +107 -0
  43. package/dist/commands/sipnet/acls/delete.d.ts +9 -0
  44. package/dist/commands/sipnet/acls/delete.js +87 -0
  45. package/dist/commands/sipnet/acls/get.d.ts +9 -0
  46. package/dist/commands/sipnet/acls/get.js +100 -0
  47. package/dist/commands/sipnet/acls/list.d.ts +9 -0
  48. package/dist/commands/sipnet/acls/list.js +99 -0
  49. package/dist/commands/sipnet/acls/update.d.ts +9 -0
  50. package/dist/commands/sipnet/acls/update.js +123 -0
  51. package/dist/commands/sipnet/agents/create.d.ts +6 -0
  52. package/dist/commands/sipnet/agents/create.js +132 -0
  53. package/dist/commands/sipnet/agents/delete.d.ts +9 -0
  54. package/dist/commands/sipnet/agents/delete.js +87 -0
  55. package/dist/commands/sipnet/agents/get.d.ts +9 -0
  56. package/dist/commands/sipnet/agents/get.js +109 -0
  57. package/dist/commands/sipnet/agents/list.d.ts +9 -0
  58. package/dist/commands/sipnet/agents/list.js +99 -0
  59. package/dist/commands/sipnet/agents/update.d.ts +9 -0
  60. package/dist/commands/sipnet/agents/update.js +149 -0
  61. package/dist/commands/sipnet/calls/create.d.ts +13 -0
  62. package/dist/commands/sipnet/calls/create.js +156 -0
  63. package/dist/commands/sipnet/calls/get.d.ts +9 -0
  64. package/dist/commands/sipnet/calls/get.js +104 -0
  65. package/dist/commands/sipnet/calls/list.d.ts +9 -0
  66. package/dist/commands/sipnet/calls/list.js +108 -0
  67. package/dist/commands/sipnet/credentials/create.d.ts +6 -0
  68. package/dist/commands/sipnet/credentials/create.js +110 -0
  69. package/dist/commands/sipnet/credentials/delete.d.ts +9 -0
  70. package/dist/commands/sipnet/credentials/delete.js +87 -0
  71. package/dist/commands/sipnet/credentials/get.d.ts +9 -0
  72. package/dist/commands/sipnet/credentials/get.js +100 -0
  73. package/dist/commands/sipnet/credentials/list.d.ts +9 -0
  74. package/dist/commands/sipnet/credentials/list.js +99 -0
  75. package/dist/commands/sipnet/credentials/update.d.ts +9 -0
  76. package/dist/commands/sipnet/credentials/update.js +121 -0
  77. package/dist/commands/sipnet/domains/create.d.ts +6 -0
  78. package/dist/commands/sipnet/domains/create.js +107 -0
  79. package/dist/commands/sipnet/domains/delete.d.ts +9 -0
  80. package/dist/commands/sipnet/domains/delete.js +87 -0
  81. package/dist/commands/sipnet/domains/get.d.ts +9 -0
  82. package/dist/commands/sipnet/domains/get.js +100 -0
  83. package/dist/commands/sipnet/domains/list.d.ts +9 -0
  84. package/dist/commands/sipnet/domains/list.js +99 -0
  85. package/dist/commands/sipnet/domains/update.d.ts +9 -0
  86. package/dist/commands/sipnet/domains/update.js +118 -0
  87. package/dist/commands/sipnet/numbers/create.d.ts +6 -0
  88. package/dist/commands/sipnet/numbers/create.js +148 -0
  89. package/dist/commands/sipnet/numbers/delete.d.ts +9 -0
  90. package/dist/commands/sipnet/numbers/delete.js +87 -0
  91. package/dist/commands/sipnet/numbers/get.d.ts +9 -0
  92. package/dist/commands/sipnet/numbers/get.js +119 -0
  93. package/dist/commands/sipnet/numbers/linkTwilioNumber.d.ts +10 -0
  94. package/dist/commands/sipnet/numbers/linkTwilioNumber.js +150 -0
  95. package/dist/commands/sipnet/numbers/list.d.ts +9 -0
  96. package/dist/commands/sipnet/numbers/list.js +111 -0
  97. package/dist/commands/sipnet/numbers/update.d.ts +9 -0
  98. package/dist/commands/sipnet/numbers/update.js +136 -0
  99. package/dist/commands/sipnet/trunks/create.d.ts +6 -0
  100. package/dist/commands/sipnet/trunks/create.js +156 -0
  101. package/dist/commands/sipnet/trunks/delete.d.ts +9 -0
  102. package/dist/commands/sipnet/trunks/delete.js +87 -0
  103. package/dist/commands/sipnet/trunks/get.d.ts +9 -0
  104. package/dist/commands/sipnet/trunks/get.js +120 -0
  105. package/dist/commands/sipnet/trunks/list.d.ts +9 -0
  106. package/dist/commands/sipnet/trunks/list.js +99 -0
  107. package/dist/commands/sipnet/trunks/update.d.ts +9 -0
  108. package/dist/commands/sipnet/trunks/update.js +174 -0
  109. package/dist/commands/workspaces/current.d.ts +6 -0
  110. package/dist/commands/workspaces/current.js +46 -0
  111. package/dist/commands/workspaces/list.d.ts +6 -0
  112. package/dist/commands/workspaces/list.js +53 -0
  113. package/dist/commands/workspaces/login.d.ts +8 -0
  114. package/dist/commands/workspaces/login.js +145 -0
  115. package/dist/commands/workspaces/logout.d.ts +9 -0
  116. package/dist/commands/workspaces/logout.js +55 -0
  117. package/dist/commands/workspaces/use.d.ts +9 -0
  118. package/dist/commands/workspaces/use.js +57 -0
  119. package/dist/config/addWorkspace.d.ts +3 -0
  120. package/dist/config/addWorkspace.js +15 -0
  121. package/dist/config/getConfig.d.ts +3 -0
  122. package/dist/config/getConfig.js +34 -0
  123. package/dist/config/getCurrentWorkspace.d.ts +3 -0
  124. package/dist/config/getCurrentWorkspace.js +6 -0
  125. package/dist/config/index.d.ts +7 -0
  126. package/dist/config/index.js +41 -0
  127. package/dist/config/removeWorkspace.d.ts +3 -0
  128. package/dist/config/removeWorkspace.js +6 -0
  129. package/dist/config/saveConfig.d.ts +3 -0
  130. package/dist/config/saveConfig.js +32 -0
  131. package/dist/config/setCurrentWorkspace.d.ts +3 -0
  132. package/dist/config/setCurrentWorkspace.js +11 -0
  133. package/dist/config/types.d.ts +4 -0
  134. package/dist/config/types.js +2 -0
  135. package/dist/config/validations.d.ts +27 -0
  136. package/dist/config/validations.js +34 -0
  137. package/dist/constants.d.ts +6 -0
  138. package/dist/constants.js +29 -0
  139. package/dist/errorHandler.d.ts +2 -0
  140. package/dist/errorHandler.js +31 -0
  141. package/dist/utils/assignTwilioNumberToTrunk.d.ts +3 -0
  142. package/dist/utils/assignTwilioNumberToTrunk.js +33 -0
  143. package/dist/utils/calculateFutureDate.d.ts +2 -0
  144. package/dist/utils/calculateFutureDate.js +37 -0
  145. package/dist/utils/createTwilioTrunk.d.ts +4 -0
  146. package/dist/utils/createTwilioTrunk.js +54 -0
  147. package/dist/utils/getFonosterNumberByTelUrl.d.ts +4 -0
  148. package/dist/utils/getFonosterNumberByTelUrl.js +76 -0
  149. package/dist/utils/getFonosterTrunkByInboundUri.d.ts +4 -0
  150. package/dist/utils/getFonosterTrunkByInboundUri.js +76 -0
  151. package/dist/utils/getOutboundUri.d.ts +7 -0
  152. package/dist/utils/getOutboundUri.js +10 -0
  153. package/dist/utils/getTwilioNumber.d.ts +4 -0
  154. package/dist/utils/getTwilioNumber.js +23 -0
  155. package/dist/utils/getTwilioTrunk.d.ts +4 -0
  156. package/dist/utils/getTwilioTrunk.js +23 -0
  157. package/dist/utils/index.d.ts +9 -0
  158. package/dist/utils/index.js +43 -0
  159. package/dist/utils/linkTwilioNumberToApplication.d.ts +5 -0
  160. package/dist/utils/linkTwilioNumberToApplication.js +128 -0
  161. package/dist/utils/types.d.ts +14 -0
  162. package/dist/utils/types.js +2 -0
  163. package/package.json +3 -3
@@ -0,0 +1,119 @@
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 AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
72
+ const config_1 = require("../../../config");
73
+ const constants_1 = require("../../../constants");
74
+ class Get extends AuthenticatedCommand_1.AuthenticatedCommand {
75
+ run() {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ var _a, _b, _c, _d, _e, _f;
78
+ 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
+ }
84
+ const client = yield this.createSdkClient();
85
+ const numbers = new SDK.Numbers(client);
86
+ const response = yield numbers.getNumber(args.ref);
87
+ const apps = new SDK.Applications(client);
88
+ let app;
89
+ try {
90
+ app = yield apps.getApplication(response.appRef);
91
+ }
92
+ catch (e) {
93
+ // You can only try
94
+ }
95
+ const ui = (0, cliui_1.default)({ width: 200 });
96
+ ui.div("NUMBER DETAILS\n" +
97
+ "------------------\n" +
98
+ `NAME: \t${response.name}\n` +
99
+ `REF: \t${response.ref}\n` +
100
+ `TEL URL: \t${response.telUrl}\n` +
101
+ `APP: \t${(_a = app === null || app === void 0 ? void 0 : app.name) !== null && _a !== void 0 ? _a : ""}\n` +
102
+ `APP REF: \t${(_b = app === null || app === void 0 ? void 0 : app.ref) !== null && _b !== void 0 ? _b : ""}\n` +
103
+ `CITY: \t${response.city}\n` +
104
+ `TRUNK NAME: \t${(_d = (_c = response.trunk) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : ""}\n` +
105
+ `TRUNK REF: \t${(_f = (_e = response.trunk) === null || _e === void 0 ? void 0 : _e.ref) !== null && _f !== void 0 ? _f : ""}\n` +
106
+ `COUNTRY ISO CODE: \t${response.countryIsoCode}\n` +
107
+ `COUNTRY: \t${response.country}\n` +
108
+ `CREATED: \t${(0, moment_1.default)(response.createdAt).format("YYYY-MM-DD HH:mm:ss")}\n` +
109
+ `UPDATED: \t${(0, moment_1.default)(response.updatedAt).format("YYYY-MM-DD HH:mm:ss")}`);
110
+ this.log(ui.toString());
111
+ });
112
+ }
113
+ }
114
+ Get.description = "retrieve details of a Number by reference";
115
+ Get.examples = ["<%= config.bin %> <%= command.id %>"];
116
+ Get.args = {
117
+ ref: core_1.Args.string({ description: "the Number to show details about" })
118
+ };
119
+ exports.default = Get;
@@ -0,0 +1,10 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class LinkTwilioNumber extends AuthenticatedCommand<typeof LinkTwilioNumber> {
3
+ static readonly description = "associate a Twilio number with a Fonoster Application";
4
+ static readonly examples: string[];
5
+ static readonly 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
+ }
@@ -0,0 +1,150 @@
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 Fonoster = __importStar(require("@fonoster/sdk"));
65
+ const prompts_1 = require("@inquirer/prompts");
66
+ const core_1 = require("@oclif/core");
67
+ const twilio_1 = require("twilio");
68
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
69
+ const config_1 = require("../../../config");
70
+ const constants_1 = require("../../../constants");
71
+ const utils_1 = require("../../../utils");
72
+ class LinkTwilioNumber extends AuthenticatedCommand_1.AuthenticatedCommand {
73
+ run() {
74
+ return __awaiter(this, void 0, void 0, function* () {
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
+ const fonosterClient = yield this.createSdkClient();
83
+ const applications = new Fonoster.Applications(fonosterClient);
84
+ const appsList = (yield applications.listApplications({ pageSize: 1000 })).items.map((app) => ({
85
+ name: app.name,
86
+ value: app.ref
87
+ }));
88
+ this.log("This utility will help you create an Application.");
89
+ this.log("Press ^C at any time to quit.");
90
+ const answers = {
91
+ number: yield (0, prompts_1.input)({
92
+ message: "Number to link (E.164 format)",
93
+ required: true
94
+ }),
95
+ friendlyName: yield (0, prompts_1.input)({
96
+ message: "Friendly Name"
97
+ }),
98
+ applicationRef: yield (0, prompts_1.select)({
99
+ message: "Application",
100
+ choices: [{ name: "None", value: null }].concat(appsList)
101
+ }),
102
+ twilioAccountSid: yield (0, prompts_1.input)({
103
+ message: "Twilio Account SID",
104
+ required: true
105
+ }),
106
+ twilioAuthToken: yield (0, prompts_1.password)({
107
+ message: "Twilio Auth Token"
108
+ }),
109
+ confirm: yield (0, prompts_1.confirm)({
110
+ message: "Ready?"
111
+ })
112
+ };
113
+ if (!answers.confirm) {
114
+ this.log("Aborted!");
115
+ return;
116
+ }
117
+ try {
118
+ const twilioClient = new twilio_1.Twilio(answers.twilioAccountSid, answers.twilioAuthToken);
119
+ yield (0, utils_1.linkTwilioNumberToApplication)(twilioClient, fonosterClient, {
120
+ phoneNumber: answers.number,
121
+ accessKeyId,
122
+ aclEntries: flags["access-control-list"].split(","),
123
+ originationUriBase: flags["outbound-uri-base"],
124
+ applicationRef: answers.applicationRef,
125
+ friendlyName: answers.friendlyName
126
+ });
127
+ }
128
+ catch (error) {
129
+ this.error(`Failed to link number: ${error.message}`);
130
+ }
131
+ });
132
+ }
133
+ }
134
+ LinkTwilioNumber.description = "associate a Twilio number with a Fonoster Application";
135
+ LinkTwilioNumber.examples = ["<%= config.bin %> <%= command.id %>"];
136
+ LinkTwilioNumber.flags = {
137
+ "outbound-uri-base": core_1.Flags.string({
138
+ char: "b",
139
+ description: "the uri to point twilio to for outbound calls (use if running your Fonoster instance)",
140
+ default: constants_1.FONOSTER_ORIGINATION_URI_BASE,
141
+ required: false
142
+ }),
143
+ "access-control-list": core_1.Flags.string({
144
+ char: "a",
145
+ description: "the access control list to allow (use if running your Fonoster instance)",
146
+ default: constants_1.FONOSTER_ACCESS_CONTROL_LIST.join(","),
147
+ required: false
148
+ })
149
+ };
150
+ exports.default = LinkTwilioNumber;
@@ -0,0 +1,9 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class List extends AuthenticatedCommand<typeof List> {
3
+ static readonly description = "display all Numbers in the active Workspace";
4
+ static readonly examples: string[];
5
+ static readonly flags: {
6
+ "page-size": import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,111 @@
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 AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
71
+ const config_1 = require("../../../config");
72
+ const constants_1 = require("../../../constants");
73
+ class List extends AuthenticatedCommand_1.AuthenticatedCommand {
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 = yield this.createSdkClient();
83
+ const numbers = new SDK.Numbers(client);
84
+ const response = yield numbers.listNumbers({
85
+ pageSize: parseInt(flags["page-size"])
86
+ });
87
+ const ui = (0, cliui_1.default)({ width: 200 });
88
+ ui.div({ text: "REF", padding: [0, 0, 0, 0], width: 40 }, { text: "NAME", padding: [0, 0, 0, 0], width: 30 }, { text: "TEL URL", padding: [0, 0, 0, 0], width: 25 }, { text: "APP REF", padding: [0, 0, 0, 0], width: 40 });
89
+ response.items.forEach((number) => {
90
+ var _a;
91
+ ui.div({ text: number.ref, padding: [0, 0, 0, 0], width: 40 }, { text: number.name, padding: [0, 0, 0, 0], width: 30 }, {
92
+ text: `${number.telUrl} (${number.countryIsoCode})`,
93
+ padding: [0, 0, 0, 0],
94
+ width: 25
95
+ }, { text: (_a = number.appRef) !== null && _a !== void 0 ? _a : "", padding: [0, 0, 0, 0], width: 40 });
96
+ });
97
+ this.log(ui.toString());
98
+ });
99
+ }
100
+ }
101
+ List.description = "display all Numbers in the active Workspace";
102
+ List.examples = ["<%= config.bin %> <%= command.id %>"];
103
+ List.flags = {
104
+ "page-size": core_1.Flags.string({
105
+ char: "s",
106
+ description: "the number of items to return",
107
+ default: "1000",
108
+ required: false
109
+ })
110
+ };
111
+ exports.default = List;
@@ -0,0 +1,9 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class Update extends AuthenticatedCommand<typeof Update> {
3
+ static readonly description = "modify the configuration of a Number";
4
+ static readonly examples: string[];
5
+ static readonly args: {
6
+ ref: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,136 @@
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 prompts_1 = require("@inquirer/prompts");
69
+ const AuthenticatedCommand_1 = require("../../../AuthenticatedCommand");
70
+ const errorHandler_1 = __importDefault(require("../../../errorHandler"));
71
+ const core_1 = require("@oclif/core");
72
+ class Update extends AuthenticatedCommand_1.AuthenticatedCommand {
73
+ run() {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ var _a;
76
+ this.log("This utility will help you update a Number.");
77
+ this.log("Press ^C at any time to quit.");
78
+ const { args } = yield this.parse(Update);
79
+ const { ref } = args;
80
+ const client = yield this.createSdkClient();
81
+ const trunks = new SDK.Trunks(client);
82
+ const applications = new SDK.Applications(client);
83
+ const numbers = new SDK.Numbers(client);
84
+ const applicationFromDB = yield numbers.getNumber(ref);
85
+ if (!applicationFromDB) {
86
+ this.error("Application not found.");
87
+ }
88
+ const trunksList = (yield trunks.listTrunks({ pageSize: 1000 })).items.map((item) => ({
89
+ name: item.name,
90
+ value: item.ref
91
+ }));
92
+ const applicationsList = (yield applications.listApplications({ pageSize: 1000 })).items.map((item) => ({
93
+ name: item.name,
94
+ value: item.ref
95
+ }));
96
+ const answers = {
97
+ ref,
98
+ name: yield (0, prompts_1.input)({
99
+ message: "Friendly name",
100
+ required: true,
101
+ default: applicationFromDB.name
102
+ }),
103
+ trunkRef: yield (0, prompts_1.select)({
104
+ message: "Trunk",
105
+ choices: [{ name: "None", value: null }].concat(trunksList),
106
+ default: (_a = applicationFromDB.trunk) === null || _a === void 0 ? void 0 : _a.ref
107
+ }),
108
+ appRef: yield (0, prompts_1.select)({
109
+ message: "Application",
110
+ choices: [{ name: "None", value: null }].concat(applicationsList),
111
+ default: applicationFromDB.appRef
112
+ }),
113
+ confirm: yield (0, prompts_1.confirm)({
114
+ message: "Ready?"
115
+ })
116
+ };
117
+ if (!answers.confirm) {
118
+ this.log("Aborted!");
119
+ return;
120
+ }
121
+ try {
122
+ yield numbers.updateNumber(answers);
123
+ this.log("Done!");
124
+ }
125
+ catch (e) {
126
+ (0, errorHandler_1.default)(e, this.error.bind(this));
127
+ }
128
+ });
129
+ }
130
+ }
131
+ Update.description = "modify the configuration of a Number";
132
+ Update.examples = ["<%= config.bin %> <%= command.id %>"];
133
+ Update.args = {
134
+ ref: core_1.Args.string({ description: "the Number to update" })
135
+ };
136
+ exports.default = Update;
@@ -0,0 +1,6 @@
1
+ import { AuthenticatedCommand } from "../../../AuthenticatedCommand";
2
+ export default class Create extends AuthenticatedCommand<typeof Create> {
3
+ static readonly description = "add a new Trunk to the SIP network";
4
+ static readonly examples: string[];
5
+ run(): Promise<void>;
6
+ }