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

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.
@@ -61,103 +61,103 @@ class CreateNumberCommand extends base_1.BaseCommand {
61
61
  async run() {
62
62
  const { flags } = await this.parse(CreateNumberCommand);
63
63
  const { endpoint, insecure } = flags;
64
- this.log("This utility will help you create a new Number.");
65
- this.log("Press ^C at any time to quit.");
66
- const searcher = new fuzzy_search_1.default(countries_1.countries, ["name"], {
67
- caseSensitive: false
68
- });
69
- const trunks = await new sdk_1.default.Trunks({ endpoint, insecure }).listTrunks({
70
- pageSize: 25,
71
- pageToken: ""
72
- });
73
- const trunksChoices = trunks.items.map((trunk) => {
74
- return {
75
- name: trunk.name,
76
- value: trunk.ref
77
- };
78
- });
79
- const answers = await inquirer_1.default.prompt([
80
- {
81
- name: "name",
82
- message: "Friendly Name",
83
- type: "input",
84
- validate: validators_1.nameValidator
85
- },
86
- {
87
- name: "telUrl",
88
- message: "Telephony URL",
89
- type: "input",
90
- validate: validators_1.telUrlValidator
91
- },
92
- {
93
- name: "aorLink",
94
- message: "AOR Link",
95
- type: "input",
96
- validate: validators_1.aorLinkValidator
97
- },
98
- {
99
- name: "trunkRef",
100
- message: "Trunk",
101
- type: "list",
102
- choices: [{ name: "None", value: undefined }, ...trunksChoices]
103
- },
104
- {
105
- name: "city",
106
- message: "City",
107
- type: "input",
108
- validate: (input) => {
109
- if (input.length === 0) {
110
- return "the city is required";
64
+ try {
65
+ const searcher = new fuzzy_search_1.default(countries_1.countries, ["name"], {
66
+ caseSensitive: false
67
+ });
68
+ const trunks = await new sdk_1.default.Trunks({ endpoint, insecure }).listTrunks({
69
+ pageSize: 25,
70
+ pageToken: ""
71
+ });
72
+ const trunksChoices = trunks.items.map((trunk) => {
73
+ return {
74
+ name: trunk.name,
75
+ value: trunk.ref
76
+ };
77
+ });
78
+ this.log("This utility will help you create a new Number.");
79
+ this.log("Press ^C at any time to quit.");
80
+ const answers = await inquirer_1.default.prompt([
81
+ {
82
+ name: "name",
83
+ message: "Friendly Name",
84
+ type: "input",
85
+ validate: validators_1.nameValidator
86
+ },
87
+ {
88
+ name: "telUrl",
89
+ message: "Telephony URL",
90
+ type: "input",
91
+ validate: validators_1.telUrlValidator
92
+ },
93
+ {
94
+ name: "aorLink",
95
+ message: "AOR Link",
96
+ type: "input",
97
+ validate: validators_1.aorLinkValidator
98
+ },
99
+ {
100
+ name: "trunkRef",
101
+ message: "Trunk",
102
+ type: "list",
103
+ choices: [{ name: "None", value: undefined }, ...trunksChoices]
104
+ },
105
+ {
106
+ name: "city",
107
+ message: "City",
108
+ type: "input",
109
+ validate: (input) => {
110
+ if (input.length === 0) {
111
+ return "the city is required";
112
+ }
113
+ return true;
111
114
  }
112
- return true;
115
+ },
116
+ {
117
+ type: "autocomplete",
118
+ name: "countryISOCode",
119
+ message: "Select a Country",
120
+ source: (_, input) => searcher.search(input)
121
+ },
122
+ {
123
+ name: "sessionAffinityHeader",
124
+ message: "Session Affinity Header",
125
+ type: "input",
126
+ validate: validators_1.sessionAffinityHeaderValidator
127
+ },
128
+ {
129
+ name: "extraHeaders",
130
+ message: "Extra Headers",
131
+ type: "input",
132
+ validate: validators_1.headersValidator
133
+ },
134
+ {
135
+ name: "confirm",
136
+ message: "Ready?",
137
+ type: "confirm"
113
138
  }
114
- },
115
- {
116
- type: "autocomplete",
117
- name: "countryISOCode",
118
- message: "Select a Country",
119
- source: (_, input) => searcher.search(input)
120
- },
121
- {
122
- name: "sessionAffinityHeader",
123
- message: "Session Affinity Header",
124
- type: "input",
125
- validate: validators_1.sessionAffinityHeaderValidator
126
- },
127
- {
128
- name: "extraHeaders",
129
- message: "Extra Headers",
130
- type: "input",
131
- validate: validators_1.headersValidator
132
- },
133
- {
134
- name: "confirm",
135
- message: "Ready?",
136
- type: "confirm"
139
+ ]);
140
+ // Re-write extraHeaders
141
+ answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
142
+ answers.country = countries_1.countries.find((country) => country.value === answers.countryISOCode).name;
143
+ if (!answers.confirm) {
144
+ this.warn("Aborted");
137
145
  }
138
- ]);
139
- // Re-write extraHeaders
140
- answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
141
- answers.country = countries_1.countries.find((country) => country.value === answers.countryISOCode).name;
142
- if (!answers.confirm) {
143
- this.warn("Aborted");
144
- }
145
- else {
146
- try {
146
+ else {
147
147
  core_1.CliUx.ux.action.start(`Creating Number ${answers.name}`);
148
148
  const api = new sdk_1.default.Numbers({ endpoint, insecure });
149
149
  const number = await api.createNumber(answers);
150
150
  await core_1.CliUx.ux.wait(1000);
151
151
  core_1.CliUx.ux.action.stop(number.ref);
152
152
  }
153
- catch (e) {
154
- core_1.CliUx.ux.action.stop();
155
- if (e.code === grpc.status.ALREADY_EXISTS) {
156
- throw new errors_1.CLIError("This Number already exist");
157
- }
158
- else {
159
- throw new errors_1.CLIError(e.message);
160
- }
153
+ }
154
+ catch (e) {
155
+ core_1.CliUx.ux.action.stop();
156
+ if (e.code === grpc.status.ALREADY_EXISTS) {
157
+ throw new errors_1.CLIError("This Number already exist");
158
+ }
159
+ else {
160
+ throw new errors_1.CLIError(e.message);
161
161
  }
162
162
  }
163
163
  }
@@ -36,81 +36,81 @@ class UpdateCommand extends base_1.BaseCommand {
36
36
  var _a;
37
37
  const { args, flags } = await this.parse(UpdateCommand);
38
38
  const { endpoint, insecure } = flags;
39
- const api = new sdk_1.default.Numbers({ endpoint, insecure });
40
- this.log("This utility will help you update an existing Number.");
41
- this.log("Press ^C at any time to quit.");
42
- const numberFromDB = await api.getNumber(args.ref);
43
- const trunks = await new sdk_1.default.Trunks({ endpoint, insecure }).listTrunks({
44
- pageSize: 25,
45
- pageToken: ""
46
- });
47
- const trunksChoices = trunks.items.map((trunk) => {
48
- return {
49
- name: trunk.name,
50
- value: trunk.ref
51
- };
52
- });
53
- const answers = await inquirer_1.default.prompt([
54
- {
55
- name: "name",
56
- message: "Friendly Name",
57
- type: "input",
58
- default: numberFromDB.name,
59
- validate: validators_1.nameValidator
60
- },
61
- {
62
- name: "aorLink",
63
- message: "AOR Link",
64
- type: "input",
65
- default: numberFromDB.aorLink || undefined,
66
- validate: validators_1.aorLinkValidator
67
- },
68
- {
69
- name: "trunkRef",
70
- message: "Trunk",
71
- type: "list",
72
- choices: [{ name: "None", value: undefined }, ...trunksChoices],
73
- default: numberFromDB.trunkRef
74
- },
75
- {
76
- name: "sessionAffinityHeader",
77
- message: "Session Affinity Header",
78
- type: "input",
79
- default: numberFromDB.sessionAffinityHeader || undefined,
80
- validate: validators_1.sessionAffinityHeaderValidator
81
- },
82
- {
83
- name: "extraHeaders",
84
- message: "Extra Headers",
85
- type: "input",
86
- default: ((_a = numberFromDB.extraHeaders) === null || _a === void 0 ? void 0 : _a.map((header) => {
87
- return `${header.name}:${header.value}`;
88
- }).join(",")) || undefined,
89
- validate: validators_1.headersValidator
90
- },
91
- {
92
- name: "confirm",
93
- message: "Ready?",
94
- type: "confirm"
39
+ try {
40
+ const api = new sdk_1.default.Numbers({ endpoint, insecure });
41
+ const numberFromDB = await api.getNumber(args.ref);
42
+ const trunks = await new sdk_1.default.Trunks({ endpoint, insecure }).listTrunks({
43
+ pageSize: 25,
44
+ pageToken: ""
45
+ });
46
+ const trunksChoices = trunks.items.map((trunk) => {
47
+ return {
48
+ name: trunk.name,
49
+ value: trunk.ref
50
+ };
51
+ });
52
+ this.log("This utility will help you update an existing Number.");
53
+ this.log("Press ^C at any time to quit.");
54
+ const answers = await inquirer_1.default.prompt([
55
+ {
56
+ name: "name",
57
+ message: "Friendly Name",
58
+ type: "input",
59
+ default: numberFromDB.name,
60
+ validate: validators_1.nameValidator
61
+ },
62
+ {
63
+ name: "aorLink",
64
+ message: "AOR Link",
65
+ type: "input",
66
+ default: numberFromDB.aorLink || undefined,
67
+ validate: validators_1.aorLinkValidator
68
+ },
69
+ {
70
+ name: "trunkRef",
71
+ message: "Trunk",
72
+ type: "list",
73
+ choices: [{ name: "None", value: undefined }, ...trunksChoices],
74
+ default: numberFromDB.trunkRef
75
+ },
76
+ {
77
+ name: "sessionAffinityHeader",
78
+ message: "Session Affinity Header",
79
+ type: "input",
80
+ default: numberFromDB.sessionAffinityHeader || undefined,
81
+ validate: validators_1.sessionAffinityHeaderValidator
82
+ },
83
+ {
84
+ name: "extraHeaders",
85
+ message: "Extra Headers",
86
+ type: "input",
87
+ default: ((_a = numberFromDB.extraHeaders) === null || _a === void 0 ? void 0 : _a.map((header) => {
88
+ return `${header.name}:${header.value}`;
89
+ }).join(",")) || undefined,
90
+ validate: validators_1.headersValidator
91
+ },
92
+ {
93
+ name: "confirm",
94
+ message: "Ready?",
95
+ type: "confirm"
96
+ }
97
+ ]);
98
+ answers.ref = args.ref;
99
+ // Re-write extraHeaders
100
+ answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
101
+ if (!answers.confirm) {
102
+ this.warn("Aborted");
95
103
  }
96
- ]);
97
- answers.ref = args.ref;
98
- // Re-write extraHeaders
99
- answers.extraHeaders = (0, utils_1.stringToHeaders)(answers.extraHeaders);
100
- if (!answers.confirm) {
101
- this.warn("Aborted");
102
- }
103
- else {
104
- try {
104
+ else {
105
105
  core_1.CliUx.ux.action.start(`Updating Number ${answers.name}`);
106
106
  const number = await api.updateNumber(answers);
107
107
  await core_1.CliUx.ux.wait(1000);
108
108
  core_1.CliUx.ux.action.stop(number.ref);
109
109
  }
110
- catch (e) {
111
- core_1.CliUx.ux.action.stop();
112
- throw new errors_1.CLIError(e.message);
113
- }
110
+ }
111
+ catch (e) {
112
+ core_1.CliUx.ux.action.stop();
113
+ throw new errors_1.CLIError(e.message);
114
114
  }
115
115
  }
116
116
  }
@@ -60,110 +60,113 @@ class CreateCommand extends base_1.BaseCommand {
60
60
  var _a, _b;
61
61
  const { flags } = await this.parse(CreateCommand);
62
62
  const { endpoint, insecure } = flags;
63
- this.log("This utility will help you create a new Peer.");
64
- this.log("Press ^C at any time to quit.");
65
- // TODO: Fix hardcoded pageSize
66
- const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
67
- pageSize: 25,
68
- pageToken: ""
69
- });
70
- // TODO: Fix hardcoded pageSize
71
- const credentials = await new sdk_1.default.Credentials({
72
- endpoint,
73
- insecure
74
- }).listCredentials({
75
- pageSize: 25,
76
- pageToken: ""
77
- });
78
- const aclList = ((_a = acls.items) === null || _a === void 0 ? void 0 : _a.map((acl) => {
79
- return { name: acl.name, value: acl.ref };
80
- })) || [];
81
- const credentialsList = ((_b = credentials.items) === null || _b === void 0 ? void 0 : _b.map((credential) => {
82
- return { name: credential.name, value: credential.ref };
83
- })) || [];
84
- const answers = await inquirer_1.default.prompt([
85
- {
86
- name: "name",
87
- message: "Friendly Name",
88
- type: "input",
89
- validate: validators_1.nameValidator
90
- },
91
- {
92
- name: "username",
93
- message: "Username",
94
- type: "input",
95
- validate: validators_1.usernameValidator
96
- },
97
- {
98
- name: "aor",
99
- message: "Adress of Record",
100
- type: "input",
101
- validate: validators_1.aorValidator
102
- },
103
- {
104
- name: "contactAddr",
105
- message: "Contact Address",
106
- type: "input",
107
- validate: validators_1.contactAddrValidator
108
- },
109
- {
110
- name: "accessControlListRef",
111
- message: "IP Access Control List",
112
- choices: [{ name: "None", value: undefined }, ...aclList],
113
- type: "list"
114
- },
115
- {
116
- name: "credentialsRef",
117
- message: "Credentials Name",
118
- choices: [{ name: "None", value: undefined }, ...credentialsList],
119
- type: "list"
120
- },
121
- {
122
- name: "withSessionAffinity",
123
- message: "Enable Session Affinity?",
124
- type: "confirm",
125
- default: false,
126
- when: (answers) => answers.aor.startsWith("backend:")
127
- },
128
- {
129
- name: "balancingAlgorithm",
130
- message: "Balancing Algorithm",
131
- choices: [
132
- { name: "Round Robin", value: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN },
133
- {
134
- name: "Least Sessions",
135
- value: common_1.CommonTypes.LoadBalancingAlgorithm.LEAST_SESSIONS
136
- }
137
- ],
138
- type: "list",
139
- default: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN,
140
- when: (answers) => answers.aor.startsWith("backend:")
141
- },
142
- {
143
- name: "confirm",
144
- message: "Ready?",
145
- type: "confirm"
63
+ try {
64
+ // TODO: Fix hardcoded pageSize
65
+ const acls = await new sdk_1.default.ACL({ endpoint, insecure }).listACLs({
66
+ pageSize: 25,
67
+ pageToken: ""
68
+ });
69
+ // TODO: Fix hardcoded pageSize
70
+ const credentials = await new sdk_1.default.Credentials({
71
+ endpoint,
72
+ insecure
73
+ }).listCredentials({
74
+ pageSize: 25,
75
+ pageToken: ""
76
+ });
77
+ const aclList = ((_a = acls.items) === null || _a === void 0 ? void 0 : _a.map((acl) => {
78
+ return { name: acl.name, value: acl.ref };
79
+ })) || [];
80
+ const credentialsList = ((_b = credentials.items) === null || _b === void 0 ? void 0 : _b.map((credential) => {
81
+ return { name: credential.name, value: credential.ref };
82
+ })) || [];
83
+ this.log("This utility will help you create a new Peer.");
84
+ this.log("Press ^C at any time to quit.");
85
+ const answers = await inquirer_1.default.prompt([
86
+ {
87
+ name: "name",
88
+ message: "Friendly Name",
89
+ type: "input",
90
+ validate: validators_1.nameValidator
91
+ },
92
+ {
93
+ name: "username",
94
+ message: "Username",
95
+ type: "input",
96
+ validate: validators_1.usernameValidator
97
+ },
98
+ {
99
+ name: "aor",
100
+ message: "Adress of Record",
101
+ type: "input",
102
+ validate: validators_1.aorValidator
103
+ },
104
+ {
105
+ name: "contactAddr",
106
+ message: "Contact Address",
107
+ type: "input",
108
+ validate: validators_1.contactAddrValidator
109
+ },
110
+ {
111
+ name: "accessControlListRef",
112
+ message: "IP Access Control List",
113
+ choices: [{ name: "None", value: undefined }, ...aclList],
114
+ type: "list"
115
+ },
116
+ {
117
+ name: "credentialsRef",
118
+ message: "Credentials Name",
119
+ choices: [{ name: "None", value: undefined }, ...credentialsList],
120
+ type: "list"
121
+ },
122
+ {
123
+ name: "withSessionAffinity",
124
+ message: "Enable Session Affinity?",
125
+ type: "confirm",
126
+ default: false,
127
+ when: (answers) => answers.aor.startsWith("backend:")
128
+ },
129
+ {
130
+ name: "balancingAlgorithm",
131
+ message: "Balancing Algorithm",
132
+ choices: [
133
+ {
134
+ name: "Round Robin",
135
+ value: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN
136
+ },
137
+ {
138
+ name: "Least Sessions",
139
+ value: common_1.CommonTypes.LoadBalancingAlgorithm.LEAST_SESSIONS
140
+ }
141
+ ],
142
+ type: "list",
143
+ default: common_1.CommonTypes.LoadBalancingAlgorithm.ROUND_ROBIN,
144
+ when: (answers) => answers.aor.startsWith("backend:")
145
+ },
146
+ {
147
+ name: "confirm",
148
+ message: "Ready?",
149
+ type: "confirm"
150
+ }
151
+ ]);
152
+ if (!answers.confirm) {
153
+ this.warn("Aborted");
146
154
  }
147
- ]);
148
- if (!answers.confirm) {
149
- this.warn("Aborted");
150
- }
151
- else {
152
- try {
155
+ else {
153
156
  core_1.CliUx.ux.action.start(`Creating Peer ${answers.name}`);
154
157
  const api = new sdk_1.default.Peers({ endpoint, insecure });
155
158
  const peer = await api.createPeer(answers);
156
159
  await core_1.CliUx.ux.wait(1000);
157
160
  core_1.CliUx.ux.action.stop(peer.ref);
158
161
  }
159
- catch (e) {
160
- core_1.CliUx.ux.action.stop();
161
- if (e.code === grpc.status.ALREADY_EXISTS) {
162
- throw new errors_1.CLIError("This Peer already exist");
163
- }
164
- else {
165
- throw new errors_1.CLIError(e.message);
166
- }
162
+ }
163
+ catch (e) {
164
+ core_1.CliUx.ux.action.stop();
165
+ if (e.code === grpc.status.ALREADY_EXISTS) {
166
+ throw new errors_1.CLIError("This Peer already exist");
167
+ }
168
+ else {
169
+ throw new errors_1.CLIError(e.message);
167
170
  }
168
171
  }
169
172
  }