@routr/ctl 2.0.8-alpha.23 → 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 (47) 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/create.js +43 -43
  5. package/dist/commands/acl/describe.d.ts +10 -0
  6. package/dist/commands/acl/describe.js +62 -0
  7. package/dist/commands/acl/get.d.ts +1 -0
  8. package/dist/commands/acl/get.js +5 -20
  9. package/dist/commands/acl/update.js +43 -43
  10. package/dist/commands/agents/create.js +97 -97
  11. package/dist/commands/agents/describe.d.ts +10 -0
  12. package/dist/commands/agents/describe.js +72 -0
  13. package/dist/commands/agents/get.d.ts +1 -0
  14. package/dist/commands/agents/get.js +4 -26
  15. package/dist/commands/agents/update.js +88 -88
  16. package/dist/commands/credentials/describe.d.ts +10 -0
  17. package/dist/commands/credentials/describe.js +61 -0
  18. package/dist/commands/credentials/get.d.ts +1 -0
  19. package/dist/commands/credentials/get.js +5 -20
  20. package/dist/commands/credentials/update.js +39 -39
  21. package/dist/commands/domains/create.js +105 -105
  22. package/dist/commands/domains/describe.d.ts +10 -0
  23. package/dist/commands/domains/describe.js +78 -0
  24. package/dist/commands/domains/get.d.ts +1 -0
  25. package/dist/commands/domains/get.js +4 -24
  26. package/dist/commands/domains/update.js +99 -99
  27. package/dist/commands/numbers/create.js +88 -88
  28. package/dist/commands/numbers/describe.d.ts +10 -0
  29. package/dist/commands/numbers/describe.js +72 -0
  30. package/dist/commands/numbers/get.d.ts +1 -0
  31. package/dist/commands/numbers/get.js +4 -24
  32. package/dist/commands/numbers/update.js +69 -69
  33. package/dist/commands/peers/create.js +106 -97
  34. package/dist/commands/peers/describe.d.ts +10 -0
  35. package/dist/commands/peers/describe.js +80 -0
  36. package/dist/commands/peers/get.d.ts +1 -0
  37. package/dist/commands/peers/get.js +6 -43
  38. package/dist/commands/peers/update.js +103 -94
  39. package/dist/commands/trunks/create.js +143 -139
  40. package/dist/commands/trunks/describe.d.ts +10 -0
  41. package/dist/commands/trunks/describe.js +85 -0
  42. package/dist/commands/trunks/get.d.ts +1 -0
  43. package/dist/commands/trunks/get.js +6 -33
  44. package/dist/commands/trunks/update.js +146 -142
  45. package/dist/delete.js +8 -3
  46. package/oclif.manifest.json +267 -183
  47. package/package.json +8 -5
@@ -59,124 +59,130 @@ class CreateTrunkCommand extends base_1.BaseCommand {
59
59
  async run() {
60
60
  const { flags } = await this.parse(CreateTrunkCommand);
61
61
  const { endpoint, insecure } = flags;
62
- this.log("This utility will help you create a new Trunk.");
63
- this.log("Press ^C at any time to quit.");
64
- // TODO: Add support for pagination
65
- const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
66
- pageSize: 25,
67
- pageToken: ""
68
- });
69
- const aclChoices = acls.items.map((acl) => {
70
- return {
71
- name: acl.name,
72
- value: acl.ref
73
- };
74
- });
75
- const credentials = await new sdk_1.default.Credentials({
76
- endpoint,
77
- insecure
78
- }).listCredentials({
79
- pageSize: 25,
80
- pageToken: ""
81
- });
82
- const credentialsChoice = credentials.items.map((acl) => {
83
- return {
84
- name: acl.name,
85
- value: acl.ref
86
- };
87
- });
88
- const group1 = await inquirer_1.default.prompt([
89
- {
90
- name: "name",
91
- message: "Friendly Name",
92
- type: "input",
93
- validate: validators_1.nameValidator
94
- },
95
- {
96
- name: "inboundUri",
97
- message: "Inbound SIP URI",
98
- type: "input",
99
- validate: validators_1.inboundUriValidator
100
- },
101
- {
102
- name: "accessControlListRef",
103
- message: "IP Access Control List",
104
- type: "list",
105
- choices: [{ name: "None", value: undefined }, ...aclChoices]
106
- },
107
- {
108
- name: "inboundCredentialsRef",
109
- message: "Inbound Credentials",
110
- type: "list",
111
- choices: [{ name: "None", value: undefined }, ...credentialsChoice]
112
- },
113
- {
114
- name: "outboundCredentialsRef",
115
- message: "Outbound Credentials",
116
- type: "list",
117
- choices: [{ name: "None", value: undefined }, ...credentialsChoice]
118
- },
119
- {
120
- name: "addOutboundUri",
121
- message: "Add an Outbound SIP URI?",
122
- type: "confirm",
123
- default: false
124
- }
125
- ]);
126
- const group2Questions = [
127
- {
128
- name: "host",
129
- message: "Host",
130
- type: "input",
131
- validate: validators_1.hostValidator
132
- },
133
- {
134
- name: "port",
135
- message: "Post",
136
- type: "input",
137
- default: "5060",
138
- validate: validators_1.portValidator
139
- },
140
- {
141
- name: "transport",
142
- message: "Transport",
143
- type: "list",
144
- choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
145
- default: common_1.CommonTypes.Transport.UDP
146
- },
147
- {
148
- name: "user",
149
- message: "User Part",
150
- type: "input",
151
- validate: validators_1.optionalUsernameValidator
152
- },
153
- {
154
- name: "priority",
155
- message: "Priority",
156
- type: "input",
157
- default: "10",
158
- validate: validators_1.priorityValidator
159
- },
160
- {
161
- name: "weight",
162
- message: "Weight",
163
- type: "input",
164
- default: "10",
165
- validate: validators_1.weightValidator
166
- },
167
- {
168
- name: "addOutboundUri",
169
- message: "Add another Outbound SIP URI?",
170
- type: "confirm",
171
- default: false
172
- }
173
- ];
174
- let addOutboundUri = group1.addOutboundUri;
175
- const uris = [];
176
- // eslint-disable-next-line no-loops/no-loops
177
- while (addOutboundUri) {
178
- const group2 = await inquirer_1.default.prompt(group2Questions);
179
- if (group2.numberRef) {
62
+ try {
63
+ // TODO: Add support for pagination
64
+ const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
65
+ pageSize: 25,
66
+ pageToken: ""
67
+ });
68
+ const aclChoices = acls.items.map((acl) => {
69
+ return {
70
+ name: acl.name,
71
+ value: acl.ref
72
+ };
73
+ });
74
+ const credentials = await new sdk_1.default.Credentials({
75
+ endpoint,
76
+ insecure
77
+ }).listCredentials({
78
+ pageSize: 25,
79
+ pageToken: ""
80
+ });
81
+ const credentialsChoice = credentials.items.map((acl) => {
82
+ return {
83
+ name: acl.name,
84
+ value: acl.ref
85
+ };
86
+ });
87
+ this.log("This utility will help you create a new Trunk.");
88
+ this.log("Press ^C at any time to quit.");
89
+ const group1 = await inquirer_1.default.prompt([
90
+ {
91
+ name: "name",
92
+ message: "Friendly Name",
93
+ type: "input",
94
+ validate: validators_1.nameValidator
95
+ },
96
+ {
97
+ name: "inboundUri",
98
+ message: "Inbound SIP URI",
99
+ type: "input",
100
+ validate: validators_1.inboundUriValidator
101
+ },
102
+ {
103
+ name: "accessControlListRef",
104
+ message: "IP Access Control List",
105
+ type: "list",
106
+ choices: [{ name: "None", value: undefined }, ...aclChoices]
107
+ },
108
+ {
109
+ name: "inboundCredentialsRef",
110
+ message: "Inbound Credentials",
111
+ type: "list",
112
+ choices: [{ name: "None", value: undefined }, ...credentialsChoice]
113
+ },
114
+ {
115
+ name: "outboundCredentialsRef",
116
+ message: "Outbound Credentials",
117
+ type: "list",
118
+ choices: [{ name: "None", value: undefined }, ...credentialsChoice]
119
+ },
120
+ {
121
+ name: "sendRegister",
122
+ message: "Send Register?",
123
+ type: "confirm",
124
+ default: false
125
+ },
126
+ {
127
+ name: "addOutboundUri",
128
+ message: "Add an Outbound SIP URI?",
129
+ type: "confirm",
130
+ default: false
131
+ }
132
+ ]);
133
+ const group2Questions = [
134
+ {
135
+ name: "host",
136
+ message: "Host",
137
+ type: "input",
138
+ validate: validators_1.hostValidator
139
+ },
140
+ {
141
+ name: "port",
142
+ message: "Post",
143
+ type: "input",
144
+ default: "5060",
145
+ validate: validators_1.portValidator
146
+ },
147
+ {
148
+ name: "transport",
149
+ message: "Transport",
150
+ type: "list",
151
+ choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
152
+ default: common_1.CommonTypes.Transport.UDP
153
+ },
154
+ {
155
+ name: "user",
156
+ message: "User Part",
157
+ type: "input",
158
+ validate: validators_1.optionalUsernameValidator
159
+ },
160
+ {
161
+ name: "priority",
162
+ message: "Priority",
163
+ type: "input",
164
+ default: "10",
165
+ validate: validators_1.priorityValidator
166
+ },
167
+ {
168
+ name: "weight",
169
+ message: "Weight",
170
+ type: "input",
171
+ default: "10",
172
+ validate: validators_1.weightValidator
173
+ },
174
+ {
175
+ name: "addOutboundUri",
176
+ message: "Add another Outbound SIP URI?",
177
+ type: "confirm",
178
+ default: false
179
+ }
180
+ ];
181
+ let addOutboundUri = group1.addOutboundUri;
182
+ const uris = [];
183
+ // eslint-disable-next-line no-loops/no-loops
184
+ while (addOutboundUri) {
185
+ const group2 = await inquirer_1.default.prompt(group2Questions);
180
186
  uris.push({
181
187
  host: group2.host,
182
188
  port: group2.port,
@@ -186,21 +192,19 @@ class CreateTrunkCommand extends base_1.BaseCommand {
186
192
  weight: group2.weight,
187
193
  enabled: true
188
194
  });
195
+ addOutboundUri = group2.addOutboundUri;
189
196
  }
190
- addOutboundUri = group2.addOutboundUri;
191
- }
192
- const group3 = await inquirer_1.default.prompt([
193
- {
194
- name: "confirm",
195
- message: "Ready?",
196
- type: "confirm"
197
+ const group3 = await inquirer_1.default.prompt([
198
+ {
199
+ name: "confirm",
200
+ message: "Ready?",
201
+ type: "confirm"
202
+ }
203
+ ]);
204
+ if (!group3.confirm) {
205
+ this.warn("Aborted");
197
206
  }
198
- ]);
199
- if (!group3.confirm) {
200
- this.warn("Aborted");
201
- }
202
- else {
203
- try {
207
+ else {
204
208
  core_1.CliUx.ux.action.start(`Creating Trunk ${group1.name}`);
205
209
  const api = new sdk_1.default.Trunks({ endpoint, insecure });
206
210
  const trunk = await api.createTrunk({
@@ -210,14 +214,14 @@ class CreateTrunkCommand extends base_1.BaseCommand {
210
214
  await core_1.CliUx.ux.wait(1000);
211
215
  core_1.CliUx.ux.action.stop(trunk.ref);
212
216
  }
213
- catch (e) {
214
- core_1.CliUx.ux.action.stop();
215
- if (e.code === grpc.status.ALREADY_EXISTS) {
216
- throw new errors_1.CLIError("This Trunk already exist");
217
- }
218
- else {
219
- throw new errors_1.CLIError(e.message);
220
- }
217
+ }
218
+ catch (e) {
219
+ core_1.CliUx.ux.action.stop();
220
+ if (e.code === grpc.status.ALREADY_EXISTS) {
221
+ throw new errors_1.CLIError("This Trunk already exist");
222
+ }
223
+ else {
224
+ throw new errors_1.CLIError(e.message);
221
225
  }
222
226
  }
223
227
  }
@@ -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 = [