@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
@@ -36,131 +36,137 @@ class UpdateCommand extends base_1.BaseCommand {
36
36
  const { args, flags } = await this.parse(UpdateCommand);
37
37
  const { endpoint, insecure } = flags;
38
38
  const api = new sdk_1.default.Trunks({ endpoint, insecure });
39
- this.log("This utility will help you update an existing Trunk.");
40
- this.log("Press ^C at any time to quit.");
41
- this.warn("Adding Outbound SIP URIs will delete existing ones.");
42
- const trunkFromDB = await api.getTrunk(args.ref);
43
- // TODO: Add support for pagination
44
- const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
45
- pageSize: 25,
46
- pageToken: ""
47
- });
48
- const aclChoices = acls.items.map((acl) => {
49
- return {
50
- name: acl.name,
51
- value: acl.ref
52
- };
53
- });
54
- const credentials = await new sdk_1.default.Credentials({
55
- endpoint,
56
- insecure
57
- }).listCredentials({
58
- pageSize: 25,
59
- pageToken: ""
60
- });
61
- const credentialsChoice = credentials.items.map((acl) => {
62
- return {
63
- name: acl.name,
64
- value: acl.ref
65
- };
66
- });
67
- const group1 = await inquirer_1.default.prompt([
68
- {
69
- name: "name",
70
- message: "Friendly Name",
71
- type: "input",
72
- default: trunkFromDB.name,
73
- validate: validators_1.nameValidator
74
- },
75
- {
76
- name: "inboundUri",
77
- message: "Inbound SIP URI",
78
- type: "input",
79
- validate: validators_1.inboundUriValidator,
80
- default: trunkFromDB.inboundUri
81
- },
82
- {
83
- name: "accessControlListRef",
84
- message: "IP Access Control List",
85
- type: "list",
86
- default: trunkFromDB.accessControlListRef,
87
- choices: [{ name: "None", value: undefined }, ...aclChoices]
88
- },
89
- {
90
- name: "inboundCredentialsRef",
91
- message: "Inbound Credentials",
92
- type: "list",
93
- default: trunkFromDB.inboundCredentialsRef,
94
- choices: [{ name: "None", value: undefined }, ...credentialsChoice]
95
- },
96
- {
97
- name: "outboundCredentialsRef",
98
- message: "Outbound Credentials",
99
- type: "list",
100
- default: trunkFromDB.outboundCredentialsRef,
101
- choices: [{ name: "None", value: undefined }, ...credentialsChoice]
102
- },
103
- {
104
- name: "addOutboundUri",
105
- message: "Add an Outbound SIP URI?",
106
- type: "confirm",
107
- default: false
108
- }
109
- ]);
110
- const group2Questions = [
111
- {
112
- name: "host",
113
- message: "Host",
114
- type: "input",
115
- validate: validators_1.hostValidator
116
- },
117
- {
118
- name: "port",
119
- message: "Post",
120
- type: "input",
121
- default: "5060",
122
- validate: validators_1.portValidator
123
- },
124
- {
125
- name: "transport",
126
- message: "Transport",
127
- type: "list",
128
- choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
129
- default: common_1.CommonTypes.Transport.UDP
130
- },
131
- {
132
- name: "user",
133
- message: "User Part",
134
- type: "input",
135
- validate: validators_1.optionalUsernameValidator
136
- },
137
- {
138
- name: "priority",
139
- message: "Priority",
140
- type: "input",
141
- default: "10",
142
- validate: validators_1.priorityValidator
143
- },
144
- {
145
- name: "weight",
146
- message: "Weight",
147
- type: "input",
148
- default: "10",
149
- validate: validators_1.weightValidator
150
- },
151
- {
152
- name: "addOutboundUri",
153
- message: "Add another Outbound SIP URI?",
154
- type: "confirm",
155
- default: false
156
- }
157
- ];
158
- let addOutboundUri = group1.addOutboundUri;
159
- const uris = [];
160
- // eslint-disable-next-line no-loops/no-loops
161
- while (addOutboundUri) {
162
- const group2 = await inquirer_1.default.prompt(group2Questions);
163
- if (group2.numberRef) {
39
+ try {
40
+ const trunkFromDB = await api.getTrunk(args.ref);
41
+ // TODO: Add support for pagination
42
+ const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
43
+ pageSize: 25,
44
+ pageToken: ""
45
+ });
46
+ const aclChoices = acls.items.map((acl) => {
47
+ return {
48
+ name: acl.name,
49
+ value: acl.ref
50
+ };
51
+ });
52
+ const credentials = await new sdk_1.default.Credentials({
53
+ endpoint,
54
+ insecure
55
+ }).listCredentials({
56
+ pageSize: 25,
57
+ pageToken: ""
58
+ });
59
+ const credentialsChoice = credentials.items.map((acl) => {
60
+ return {
61
+ name: acl.name,
62
+ value: acl.ref
63
+ };
64
+ });
65
+ this.log("This utility will help you update an existing Trunk.");
66
+ this.log("Press ^C at any time to quit.");
67
+ this.warn("Adding Outbound SIP URIs will delete existing ones.");
68
+ const group1 = await inquirer_1.default.prompt([
69
+ {
70
+ name: "name",
71
+ message: "Friendly Name",
72
+ type: "input",
73
+ default: trunkFromDB.name,
74
+ validate: validators_1.nameValidator
75
+ },
76
+ {
77
+ name: "inboundUri",
78
+ message: "Inbound SIP URI",
79
+ type: "input",
80
+ validate: validators_1.inboundUriValidator,
81
+ default: trunkFromDB.inboundUri
82
+ },
83
+ {
84
+ name: "accessControlListRef",
85
+ message: "IP Access Control List",
86
+ type: "list",
87
+ default: trunkFromDB.accessControlListRef,
88
+ choices: [{ name: "None", value: undefined }, ...aclChoices]
89
+ },
90
+ {
91
+ name: "inboundCredentialsRef",
92
+ message: "Inbound Credentials",
93
+ type: "list",
94
+ default: trunkFromDB.inboundCredentialsRef,
95
+ choices: [{ name: "None", value: undefined }, ...credentialsChoice]
96
+ },
97
+ {
98
+ name: "outboundCredentialsRef",
99
+ message: "Outbound Credentials",
100
+ type: "list",
101
+ default: trunkFromDB.outboundCredentialsRef,
102
+ choices: [{ name: "None", value: undefined }, ...credentialsChoice]
103
+ },
104
+ {
105
+ name: "sendRegister",
106
+ message: "Send Register?",
107
+ type: "confirm",
108
+ default: trunkFromDB.sendRegister
109
+ },
110
+ {
111
+ name: "addOutboundUri",
112
+ message: "Add an Outbound SIP URI?",
113
+ type: "confirm",
114
+ default: false
115
+ }
116
+ ]);
117
+ const group2Questions = [
118
+ {
119
+ name: "host",
120
+ message: "Host",
121
+ type: "input",
122
+ validate: validators_1.hostValidator
123
+ },
124
+ {
125
+ name: "port",
126
+ message: "Post",
127
+ type: "input",
128
+ default: "5060",
129
+ validate: validators_1.portValidator
130
+ },
131
+ {
132
+ name: "transport",
133
+ message: "Transport",
134
+ type: "list",
135
+ choices: [common_1.CommonTypes.Transport.UDP, common_1.CommonTypes.Transport.TCP, common_1.CommonTypes.Transport.TLS],
136
+ default: common_1.CommonTypes.Transport.UDP
137
+ },
138
+ {
139
+ name: "user",
140
+ message: "User Part",
141
+ type: "input",
142
+ validate: validators_1.optionalUsernameValidator
143
+ },
144
+ {
145
+ name: "priority",
146
+ message: "Priority",
147
+ type: "input",
148
+ default: "10",
149
+ validate: validators_1.priorityValidator
150
+ },
151
+ {
152
+ name: "weight",
153
+ message: "Weight",
154
+ type: "input",
155
+ default: "10",
156
+ validate: validators_1.weightValidator
157
+ },
158
+ {
159
+ name: "addOutboundUri",
160
+ message: "Add another Outbound SIP URI?",
161
+ type: "confirm",
162
+ default: false
163
+ }
164
+ ];
165
+ let addOutboundUri = group1.addOutboundUri;
166
+ const uris = [];
167
+ // eslint-disable-next-line no-loops/no-loops
168
+ while (addOutboundUri) {
169
+ const group2 = await inquirer_1.default.prompt(group2Questions);
164
170
  uris.push({
165
171
  host: group2.host,
166
172
  port: group2.port,
@@ -170,21 +176,19 @@ class UpdateCommand extends base_1.BaseCommand {
170
176
  weight: group2.weight,
171
177
  enabled: true
172
178
  });
179
+ addOutboundUri = group2.addOutboundUri;
173
180
  }
174
- addOutboundUri = group2.addOutboundUri;
175
- }
176
- const group3 = await inquirer_1.default.prompt([
177
- {
178
- name: "confirm",
179
- message: "Ready?",
180
- type: "confirm"
181
+ const group3 = await inquirer_1.default.prompt([
182
+ {
183
+ name: "confirm",
184
+ message: "Ready?",
185
+ type: "confirm"
186
+ }
187
+ ]);
188
+ if (!group3.confirm) {
189
+ this.warn("Aborted");
181
190
  }
182
- ]);
183
- if (!group3.confirm) {
184
- this.warn("Aborted");
185
- }
186
- else {
187
- try {
191
+ else {
188
192
  core_1.CliUx.ux.action.start(`Updating Trunk ${group1.name}`);
189
193
  const trunk = await api.updateTrunk({
190
194
  ref: trunkFromDB.ref,
@@ -194,10 +198,10 @@ class UpdateCommand extends base_1.BaseCommand {
194
198
  await core_1.CliUx.ux.wait(1000);
195
199
  core_1.CliUx.ux.action.stop(trunk.ref);
196
200
  }
197
- catch (e) {
198
- core_1.CliUx.ux.action.stop();
199
- throw new errors_1.CLIError(e.message);
200
- }
201
+ }
202
+ catch (e) {
203
+ core_1.CliUx.ux.action.stop();
204
+ throw new errors_1.CLIError(e.message);
201
205
  }
202
206
  }
203
207
  }
package/dist/delete.js CHANGED
@@ -31,9 +31,14 @@ class DeleteCommand extends base_1.BaseCommand {
31
31
  throw new errors_1.CLIError("You must provide a resource ref before continuing");
32
32
  }
33
33
  core_1.CliUx.ux.action.start(`Deleting item ${args.ref}`);
34
- await API[funcName](args.ref);
35
- await core_1.CliUx.ux.wait(1000);
36
- core_1.CliUx.ux.action.stop("Done");
34
+ try {
35
+ await API[funcName](args.ref);
36
+ await core_1.CliUx.ux.wait(1000);
37
+ core_1.CliUx.ux.action.stop("Done");
38
+ }
39
+ catch (e) {
40
+ throw new errors_1.CLIError(e.message);
41
+ }
37
42
  }
38
43
  async catch(err) {
39
44
  return super.catch(err);