@routr/ctl 2.0.8-alpha.24 → 2.0.8-alpha.25

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 (39) hide show
  1. package/README.md +170 -51
  2. package/dist/base.d.ts +0 -1
  3. package/dist/base.js +0 -4
  4. package/dist/commands/acl/describe.d.ts +10 -0
  5. package/dist/commands/acl/describe.js +62 -0
  6. package/dist/commands/acl/get.d.ts +1 -0
  7. package/dist/commands/acl/get.js +4 -19
  8. package/dist/commands/agents/create.js +1 -1
  9. package/dist/commands/agents/describe.d.ts +10 -0
  10. package/dist/commands/agents/describe.js +72 -0
  11. package/dist/commands/agents/get.d.ts +1 -0
  12. package/dist/commands/agents/get.js +4 -26
  13. package/dist/commands/agents/update.js +1 -1
  14. package/dist/commands/credentials/describe.d.ts +10 -0
  15. package/dist/commands/credentials/describe.js +61 -0
  16. package/dist/commands/credentials/get.d.ts +1 -0
  17. package/dist/commands/credentials/get.js +5 -20
  18. package/dist/commands/domains/describe.d.ts +10 -0
  19. package/dist/commands/domains/describe.js +78 -0
  20. package/dist/commands/domains/get.d.ts +1 -0
  21. package/dist/commands/domains/get.js +4 -24
  22. package/dist/commands/numbers/describe.d.ts +10 -0
  23. package/dist/commands/numbers/describe.js +72 -0
  24. package/dist/commands/numbers/get.d.ts +1 -0
  25. package/dist/commands/numbers/get.js +4 -24
  26. package/dist/commands/peers/create.js +6 -0
  27. package/dist/commands/peers/describe.d.ts +10 -0
  28. package/dist/commands/peers/describe.js +80 -0
  29. package/dist/commands/peers/get.d.ts +1 -0
  30. package/dist/commands/peers/get.js +6 -43
  31. package/dist/commands/peers/update.js +6 -0
  32. package/dist/commands/trunks/create.js +15 -11
  33. package/dist/commands/trunks/describe.d.ts +10 -0
  34. package/dist/commands/trunks/describe.js +85 -0
  35. package/dist/commands/trunks/get.d.ts +1 -0
  36. package/dist/commands/trunks/get.js +6 -33
  37. package/dist/commands/trunks/update.js +15 -11
  38. package/oclif.manifest.json +267 -183
  39. package/package.json +8 -5
@@ -0,0 +1,80 @@
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) 2023 by Fonoster Inc (https://fonoster.com)
8
+ * http://github.com/fonoster
9
+ *
10
+ * This file is part of Routr.
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 require-jsdoc */
25
+ const base_1 = require("../../base");
26
+ const errors_1 = require("@oclif/core/lib/errors");
27
+ const prettyjson_1 = require("prettyjson");
28
+ const sdk_1 = __importDefault(require("@routr/sdk"));
29
+ const moment_1 = __importDefault(require("moment"));
30
+ class DescribeCommand extends base_1.BaseCommand {
31
+ async run() {
32
+ const { args, flags } = await this.parse(DescribeCommand);
33
+ const { endpoint, insecure } = flags;
34
+ const api = new sdk_1.default.Peers({ endpoint, insecure });
35
+ try {
36
+ const peer = await api.getPeer(args.ref);
37
+ const jsonObj = {
38
+ Ref: peer.ref,
39
+ APIVersion: peer.apiVersion,
40
+ Name: peer.name,
41
+ Username: peer.username,
42
+ AOR: peer.aor,
43
+ "Balancing Algorithm": peer.balancingAlgorithm,
44
+ "Session Affinity?": peer.withSessionAffinity ? "Yes" : "No",
45
+ "Contact Address": peer.contactAddr,
46
+ Enabled: peer.enabled ? "Yes" : "No",
47
+ "Access Control List": peer.accessControlList
48
+ ? {
49
+ Ref: peer.accessControlList.ref,
50
+ Name: peer.accessControlList.name,
51
+ Deny: peer.accessControlList.deny.join(","),
52
+ Allow: peer.accessControlList.allow.join(",")
53
+ }
54
+ : "None",
55
+ Credentials: peer.credentials
56
+ ? {
57
+ Ref: peer.credentials.ref,
58
+ Username: peer.credentials.username
59
+ }
60
+ : "None",
61
+ Extended: peer.extended,
62
+ Created: (0, moment_1.default)(new Date(peer.createdAt * 1000)).toISOString(),
63
+ Updated: (0, moment_1.default)(new Date(peer.updatedAt * 1000)).toISOString()
64
+ };
65
+ this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
66
+ }
67
+ catch (e) {
68
+ throw new errors_1.CLIError(e.message);
69
+ }
70
+ }
71
+ }
72
+ exports.default = DescribeCommand;
73
+ DescribeCommand.description = "shows details for a Peer";
74
+ DescribeCommand.args = [
75
+ {
76
+ name: "ref",
77
+ required: false,
78
+ description: "reference to the Peer"
79
+ }
80
+ ];
@@ -5,6 +5,7 @@ export default class GetCommand extends BaseCommand {
5
5
  static examples: string[];
6
6
  static flags: {
7
7
  size: import("@oclif/core/lib/interfaces").OptionFlag<number>;
8
+ extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
9
  };
9
10
  static args: {
10
11
  name: string;
@@ -42,12 +42,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  * limitations under the License.
43
43
  */
44
44
  /* eslint-disable require-jsdoc */
45
+ const grpc = __importStar(require("@grpc/grpc-js"));
45
46
  const core_1 = require("@oclif/core");
46
47
  const base_1 = require("../../base");
47
48
  const utils_1 = require("../../utils");
48
49
  const common_1 = require("@routr/common");
49
50
  const errors_1 = require("@oclif/core/lib/errors");
50
- const grpc = __importStar(require("@grpc/grpc-js"));
51
51
  class GetCommand extends base_1.BaseCommand {
52
52
  async run() {
53
53
  const { args, flags } = await this.parse(GetCommand);
@@ -67,50 +67,9 @@ class GetCommand extends base_1.BaseCommand {
67
67
  aor: {
68
68
  header: "AOR"
69
69
  },
70
- balancingAlgorithm: {
71
- header: "Balancing Algorithm"
72
- },
73
- withSessionAffinity: {
74
- header: "Session Affinity",
75
- get: (row) => row.withSessionAffinity ? "Yes" : "No"
76
- },
77
- contactAddr: {
78
- header: "Contact Address",
79
- extended: true
80
- },
81
70
  enabled: {
82
71
  header: "Enabled",
83
- get: (row) => (row.enabled ? "Yes" : "No"),
84
- extended: true
85
- },
86
- accessControlList: {
87
- header: "IP Access Control List",
88
- get: (row) => { var _a; return ((_a = row.accessControlList) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
89
- extended: true
90
- },
91
- credentials: {
92
- header: "Credentials Name",
93
- get: (row) => { var _a; return ((_a = row.credentials) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
94
- extended: true
95
- },
96
- createdAt: {
97
- header: "Created",
98
- get: (row) => new Date(row.createdAt * 1000),
99
- extended: true
100
- },
101
- updatedAt: {
102
- header: "Updated",
103
- get: (row) => new Date(row.updatedAt * 1000),
104
- extended: true
105
- },
106
- extended: {
107
- header: "Extended",
108
- get: (row) => row.extended || {},
109
- extended: true
110
- },
111
- apiVersion: {
112
- header: "API",
113
- extended: true
72
+ get: (row) => (row.enabled ? "Yes" : "No")
114
73
  }
115
74
  }, {
116
75
  "no-header": !showHeader,
@@ -148,6 +107,10 @@ GetCommand.flags = {
148
107
  char: "s",
149
108
  description: "the number of items to return",
150
109
  default: 50
110
+ }),
111
+ extended: core_1.Flags.boolean({
112
+ char: "x",
113
+ description: "extended output format"
151
114
  })
152
115
  };
153
116
  GetCommand.args = [
@@ -120,6 +120,12 @@ class UpdatePeerCommand extends base_1.BaseCommand {
120
120
  default: peerFromDB.balancingAlgorithm,
121
121
  when: (answers) => answers.aor.startsWith("backend:")
122
122
  },
123
+ {
124
+ name: "enabled",
125
+ message: "Enabled?",
126
+ type: "confirm",
127
+ default: peerFromDB.enabled
128
+ },
123
129
  {
124
130
  name: "confirm",
125
131
  message: "Ready?",
@@ -117,6 +117,12 @@ class CreateTrunkCommand extends base_1.BaseCommand {
117
117
  type: "list",
118
118
  choices: [{ name: "None", value: undefined }, ...credentialsChoice]
119
119
  },
120
+ {
121
+ name: "sendRegister",
122
+ message: "Send Register?",
123
+ type: "confirm",
124
+ default: false
125
+ },
120
126
  {
121
127
  name: "addOutboundUri",
122
128
  message: "Add an Outbound SIP URI?",
@@ -177,17 +183,15 @@ class CreateTrunkCommand extends base_1.BaseCommand {
177
183
  // eslint-disable-next-line no-loops/no-loops
178
184
  while (addOutboundUri) {
179
185
  const group2 = await inquirer_1.default.prompt(group2Questions);
180
- if (group2.numberRef) {
181
- uris.push({
182
- host: group2.host,
183
- port: group2.port,
184
- transport: group2.transport,
185
- user: group2.user,
186
- priority: group2.priority,
187
- weight: group2.weight,
188
- enabled: true
189
- });
190
- }
186
+ uris.push({
187
+ host: group2.host,
188
+ port: group2.port,
189
+ transport: group2.transport,
190
+ user: group2.user,
191
+ priority: group2.priority,
192
+ weight: group2.weight,
193
+ enabled: true
194
+ });
191
195
  addOutboundUri = group2.addOutboundUri;
192
196
  }
193
197
  const group3 = await inquirer_1.default.prompt([
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from "../../base";
2
+ export default class DescribeCommand extends BaseCommand {
3
+ static description: string;
4
+ static args: {
5
+ name: string;
6
+ required: boolean;
7
+ description: string;
8
+ }[];
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,85 @@
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) 2023 by Fonoster Inc (https://fonoster.com)
8
+ * http://github.com/fonoster
9
+ *
10
+ * This file is part of Routr.
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 require-jsdoc */
25
+ const base_1 = require("../../base");
26
+ const errors_1 = require("@oclif/core/lib/errors");
27
+ const prettyjson_1 = require("prettyjson");
28
+ const sdk_1 = __importDefault(require("@routr/sdk"));
29
+ const moment_1 = __importDefault(require("moment"));
30
+ class DescribeCommand extends base_1.BaseCommand {
31
+ async run() {
32
+ const { args, flags } = await this.parse(DescribeCommand);
33
+ const { endpoint, insecure } = flags;
34
+ const api = new sdk_1.default.Trunks({ endpoint, insecure });
35
+ try {
36
+ const trunk = await api.getTrunk(args.ref);
37
+ const jsonObj = {
38
+ Ref: trunk.ref,
39
+ APIVersion: trunk.apiVersion,
40
+ Name: trunk.name,
41
+ "Inbound URI": trunk.inboundUri,
42
+ "Access Control List": trunk.accessControlList
43
+ ? {
44
+ Ref: trunk.accessControlList.ref,
45
+ Name: trunk.accessControlList.name,
46
+ Deny: trunk.accessControlList.deny.join(","),
47
+ Allow: trunk.accessControlList.allow.join(",")
48
+ }
49
+ : "None",
50
+ "Inbound Credentials": trunk.inboundCredentials
51
+ ? {
52
+ Ref: trunk.inboundCredentials.ref,
53
+ Username: trunk.inboundCredentials.username
54
+ }
55
+ : "None",
56
+ "Outbound Credentials": trunk.outboundCredentials
57
+ ? {
58
+ Ref: trunk.outboundCredentials.ref,
59
+ Username: trunk.outboundCredentials.username
60
+ }
61
+ : "None",
62
+ "Outbound URIs": trunk.uris
63
+ .map((uri) => `${uri.host}:${uri.port} [transport=${uri.transport};weight=${uri.weight};priority=${uri.priority}]`)
64
+ .join(",") || "None",
65
+ "Send Register": trunk.sendRegister,
66
+ Extended: trunk.extended,
67
+ Created: (0, moment_1.default)(new Date(trunk.createdAt * 1000)).toISOString(),
68
+ Updated: (0, moment_1.default)(new Date(trunk.updatedAt * 1000)).toISOString()
69
+ };
70
+ this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
71
+ }
72
+ catch (e) {
73
+ throw new errors_1.CLIError(e.message);
74
+ }
75
+ }
76
+ }
77
+ exports.default = DescribeCommand;
78
+ DescribeCommand.description = "shows details for a Trunk";
79
+ DescribeCommand.args = [
80
+ {
81
+ name: "ref",
82
+ required: false,
83
+ description: "reference to the Trunk"
84
+ }
85
+ ];
@@ -5,6 +5,7 @@ export default class GetTrunksCommand extends BaseCommand {
5
5
  static examples: string[];
6
6
  static flags: {
7
7
  size: import("@oclif/core/lib/interfaces").OptionFlag<number>;
8
+ extended: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
9
  };
9
10
  static args: {
10
11
  name: string;
@@ -64,39 +64,8 @@ class GetTrunksCommand extends base_1.BaseCommand {
64
64
  inboundUri: {
65
65
  header: "Inbound SIP URI"
66
66
  },
67
- accessControlListRef: {
68
- header: "IP Access Control List",
69
- get: (row) => { var _a; return ((_a = row.accessControlList) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
70
- extended: true
71
- },
72
- inboundCredentialsRef: {
73
- header: "Inbound Credentials Name",
74
- get: (row) => { var _a; return ((_a = row.inboundCredentials) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
75
- extended: true
76
- },
77
- outboundCredentialsRef: {
78
- header: "Outbound Credentials Name",
79
- get: (row) => { var _a; return ((_a = row.outboundCredentials) === null || _a === void 0 ? void 0 : _a.name) || "None"; },
80
- extended: true
81
- },
82
- createdAt: {
83
- header: "Created",
84
- get: (row) => new Date(row.createdAt * 1000),
85
- extended: true
86
- },
87
- updatedAt: {
88
- header: "Updated",
89
- get: (row) => new Date(row.updatedAt * 1000),
90
- extended: true
91
- },
92
- extended: {
93
- header: "Extended",
94
- get: (row) => row.extended || {},
95
- extended: true
96
- },
97
- apiVersion: {
98
- header: "API",
99
- extended: true
67
+ sendRegister: {
68
+ header: "Send Register"
100
69
  }
101
70
  }, {
102
71
  "no-header": !showHeader,
@@ -134,6 +103,10 @@ GetTrunksCommand.flags = {
134
103
  char: "s",
135
104
  description: "the number of items to return",
136
105
  default: 50
106
+ }),
107
+ extended: core_1.Flags.boolean({
108
+ char: "x",
109
+ description: "extended output format"
137
110
  })
138
111
  };
139
112
  GetTrunksCommand.args = [
@@ -101,6 +101,12 @@ class UpdateCommand extends base_1.BaseCommand {
101
101
  default: trunkFromDB.outboundCredentialsRef,
102
102
  choices: [{ name: "None", value: undefined }, ...credentialsChoice]
103
103
  },
104
+ {
105
+ name: "sendRegister",
106
+ message: "Send Register?",
107
+ type: "confirm",
108
+ default: trunkFromDB.sendRegister
109
+ },
104
110
  {
105
111
  name: "addOutboundUri",
106
112
  message: "Add an Outbound SIP URI?",
@@ -161,17 +167,15 @@ class UpdateCommand extends base_1.BaseCommand {
161
167
  // eslint-disable-next-line no-loops/no-loops
162
168
  while (addOutboundUri) {
163
169
  const group2 = await inquirer_1.default.prompt(group2Questions);
164
- if (group2.numberRef) {
165
- uris.push({
166
- host: group2.host,
167
- port: group2.port,
168
- transport: group2.transport,
169
- user: group2.user,
170
- priority: group2.priority,
171
- weight: group2.weight,
172
- enabled: true
173
- });
174
- }
170
+ uris.push({
171
+ host: group2.host,
172
+ port: group2.port,
173
+ transport: group2.transport,
174
+ user: group2.user,
175
+ priority: group2.priority,
176
+ weight: group2.weight,
177
+ enabled: true
178
+ });
175
179
  addOutboundUri = group2.addOutboundUri;
176
180
  }
177
181
  const group3 = await inquirer_1.default.prompt([