@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
@@ -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
  }
@@ -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,72 @@
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.Numbers({ endpoint, insecure });
35
+ try {
36
+ const number = await api.getNumber(args.ref);
37
+ const jsonObj = {
38
+ Ref: number.ref,
39
+ APIVersion: number.apiVersion,
40
+ Name: number.name,
41
+ "Tel URL": number.telUrl,
42
+ "AOR Link": number.aorLink,
43
+ "Trunk Ref": number.trunkRef,
44
+ "Geo Info": {
45
+ City: number.city,
46
+ "Country Name": number.country,
47
+ "Country Code": number.countryIsoCode
48
+ },
49
+ "Session Affinity Header": number.sessionAffinityHeader,
50
+ "Extra Headers": number.extraHeaders
51
+ ? number.extraHeaders.join(",")
52
+ : "None",
53
+ Extended: number.extended,
54
+ Created: (0, moment_1.default)(new Date(number.createdAt * 1000)).toISOString(),
55
+ Updated: (0, moment_1.default)(new Date(number.updatedAt * 1000)).toISOString()
56
+ };
57
+ this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
58
+ }
59
+ catch (e) {
60
+ throw new errors_1.CLIError(e.message);
61
+ }
62
+ }
63
+ }
64
+ exports.default = DescribeCommand;
65
+ DescribeCommand.description = "shows details for a Number";
66
+ DescribeCommand.args = [
67
+ {
68
+ name: "ref",
69
+ required: false,
70
+ description: "reference to the Number"
71
+ }
72
+ ];
@@ -5,6 +5,7 @@ export default class GetNumbersCommand 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;
@@ -75,30 +75,6 @@ class GetNumbersCommand extends base_1.BaseCommand {
75
75
  header: "Geo",
76
76
  // Combine city, country and countryIsoCode
77
77
  get: (row) => `${row.city}, ${row.country} (${row.countryIsoCode})`
78
- },
79
- createdAt: {
80
- header: "Created",
81
- get: (row) => new Date(row.createdAt * 1000),
82
- extended: true
83
- },
84
- updatedAt: {
85
- header: "Updated",
86
- get: (row) => new Date(row.updatedAt * 1000),
87
- extended: true
88
- },
89
- extraHeaders: {
90
- header: "Extra Headers",
91
- get: (row) => row.extraHeaders || [{}],
92
- extended: true
93
- },
94
- extended: {
95
- header: "Extended",
96
- get: (row) => row.extended || {},
97
- extended: true
98
- },
99
- apiVersion: {
100
- header: "API",
101
- extended: true
102
78
  }
103
79
  }, {
104
80
  "no-header": !showHeader,
@@ -136,6 +112,10 @@ GetNumbersCommand.flags = {
136
112
  char: "s",
137
113
  description: "the number of items to return",
138
114
  default: 50
115
+ }),
116
+ extended: core_1.Flags.boolean({
117
+ char: "x",
118
+ description: "extended output format"
139
119
  })
140
120
  };
141
121
  GetNumbersCommand.args = [
@@ -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
  }