@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
@@ -72,35 +72,9 @@ class GetAgentsCommand extends base_1.BaseCommand {
72
72
  header: "Privacy",
73
73
  get: (row) => (0, utils_1.capitalize)(row.privacy)
74
74
  },
75
- credentials: {
76
- header: "Credentials Name",
77
- get: (row) => row.credentials
78
- ? `${row.credentials.name} (${row.credentials.username})`
79
- : "None",
80
- extended: true
81
- },
82
75
  enabled: {
83
76
  header: "Enabled",
84
77
  get: (row) => (row.enabled ? "Yes" : "No")
85
- },
86
- createdAt: {
87
- header: "Created",
88
- get: (row) => new Date(row.createdAt * 1000),
89
- extended: true
90
- },
91
- updatedAt: {
92
- header: "Updated",
93
- get: (row) => new Date(row.updatedAt * 1000),
94
- extended: true
95
- },
96
- extended: {
97
- header: "Extended",
98
- get: (row) => row.extended || {},
99
- extended: true
100
- },
101
- apiVersion: {
102
- header: "API",
103
- extended: true
104
78
  }
105
79
  }, {
106
80
  "no-header": !showHeader,
@@ -138,6 +112,10 @@ GetAgentsCommand.flags = {
138
112
  char: "s",
139
113
  description: "The number of items to return",
140
114
  default: 50
115
+ }),
116
+ extended: core_1.Flags.boolean({
117
+ char: "x",
118
+ description: "extended output format"
141
119
  })
142
120
  };
143
121
  GetAgentsCommand.args = [
@@ -37,100 +37,100 @@ class UpdateCommand extends base_1.BaseCommand {
37
37
  var _a, _b;
38
38
  const { args, flags } = await this.parse(UpdateCommand);
39
39
  const { endpoint, insecure } = flags;
40
- const api = new sdk_1.default.Agents({ endpoint, insecure });
41
- this.log("This utility will help you update an existing Agent.");
42
- this.log("Press ^C at any time to quit.");
43
- const agentFromDB = await api.getAgent(args.ref);
44
- // TODO: Fix hardcoded pageSize
45
- const domains = await new sdk_1.default.Domains({ endpoint, insecure }).listDomains({
46
- pageSize: 25,
47
- pageToken: ""
48
- });
49
- // TODO: Fix hardcoded pageSize
50
- const credentials = await new sdk_1.default.Credentials({
51
- endpoint,
52
- insecure
53
- }).listCredentials({
54
- pageSize: 25,
55
- pageToken: ""
56
- });
57
- const domainsList = (_a = domains.items) === null || _a === void 0 ? void 0 : _a.map((domain) => {
58
- return { name: domain.domainUri, value: domain.ref };
59
- });
60
- const credentialsList = (_b = credentials.items) === null || _b === void 0 ? void 0 : _b.map((credential) => {
61
- return { name: credential.name, value: credential.ref };
62
- });
63
- const searcher = new fuzzy_search_1.default(domainsList, ["name", "value", "description"], {
64
- caseSensitive: false
65
- });
66
- const answers = await inquirer_1.default.prompt([
67
- {
68
- name: "name",
69
- message: "Friendly Name",
70
- type: "input",
71
- default: agentFromDB.name,
72
- validate: validators_1.nameValidator
73
- },
74
- {
75
- type: "autocomplete",
76
- name: "domainRef",
77
- message: "Select a Domain",
78
- source: (_, input) => searcher.search(input),
79
- when: () => domains.items.length > 0
80
- },
81
- {
82
- name: "credentialsRef",
83
- message: "Credentials Name",
84
- type: "list",
85
- choices: [{ name: "None", value: undefined }, ...credentialsList],
86
- default: agentFromDB.credentialsRef
87
- },
88
- {
89
- name: "privacy",
90
- message: "Privacy",
91
- type: "list",
92
- choices: [
93
- {
94
- name: "None",
95
- value: common_1.CommonTypes.Privacy.NONE
96
- },
97
- {
98
- name: "Private",
99
- value: common_1.CommonTypes.Privacy.PRIVATE
100
- }
101
- ],
102
- default: agentFromDB.privacy
103
- },
104
- {
105
- name: "enabled",
106
- message: "Enabled",
107
- type: "confirm",
108
- default: agentFromDB.enabled
109
- },
110
- {
111
- name: "confirm",
112
- message: "Ready?",
113
- type: "confirm"
40
+ try {
41
+ const api = new sdk_1.default.Agents({ endpoint, insecure });
42
+ const agentFromDB = await api.getAgent(args.ref);
43
+ // TODO: Fix hardcoded pageSize
44
+ const domains = await new sdk_1.default.Domains({ endpoint, insecure }).listDomains({
45
+ pageSize: 25,
46
+ pageToken: ""
47
+ });
48
+ // TODO: Fix hardcoded pageSize
49
+ const credentials = await new sdk_1.default.Credentials({
50
+ endpoint,
51
+ insecure
52
+ }).listCredentials({
53
+ pageSize: 25,
54
+ pageToken: ""
55
+ });
56
+ const domainsList = (_a = domains.items) === null || _a === void 0 ? void 0 : _a.map((domain) => {
57
+ return { name: domain.domainUri, value: domain.ref };
58
+ });
59
+ const credentialsList = (_b = credentials.items) === null || _b === void 0 ? void 0 : _b.map((credential) => {
60
+ return { name: credential.name, value: credential.ref };
61
+ });
62
+ const searcher = new fuzzy_search_1.default(domainsList, ["name", "value", "description"], {
63
+ caseSensitive: false
64
+ });
65
+ this.log("This utility will help you update an existing Agent.");
66
+ this.log("Press ^C at any time to quit.");
67
+ const answers = await inquirer_1.default.prompt([
68
+ {
69
+ name: "name",
70
+ message: "Friendly Name",
71
+ type: "input",
72
+ default: agentFromDB.name,
73
+ validate: validators_1.nameValidator
74
+ },
75
+ {
76
+ type: "autocomplete",
77
+ name: "domainRef",
78
+ message: "Select a Domain",
79
+ source: (_, input) => searcher.search(input),
80
+ when: () => domains.items.length > 0
81
+ },
82
+ {
83
+ name: "credentialsRef",
84
+ message: "Credentials Name",
85
+ type: "list",
86
+ choices: [{ name: "None", value: undefined }, ...credentialsList],
87
+ default: agentFromDB.credentialsRef
88
+ },
89
+ {
90
+ name: "privacy",
91
+ message: "Privacy",
92
+ type: "list",
93
+ choices: [
94
+ {
95
+ name: "None",
96
+ value: common_1.CommonTypes.Privacy.NONE
97
+ },
98
+ {
99
+ name: "Private",
100
+ value: common_1.CommonTypes.Privacy.PRIVATE
101
+ }
102
+ ],
103
+ default: agentFromDB.privacy
104
+ },
105
+ {
106
+ name: "enabled",
107
+ message: "Enabled?",
108
+ type: "confirm",
109
+ default: agentFromDB.enabled
110
+ },
111
+ {
112
+ name: "confirm",
113
+ message: "Ready?",
114
+ type: "confirm"
115
+ }
116
+ ]);
117
+ // Re-write privacy to enum
118
+ answers.privacy =
119
+ common_1.CommonTypes.Privacy[answers.privacy.toUpperCase()];
120
+ answers.ref = args.ref;
121
+ if (!answers.confirm) {
122
+ this.warn("Aborted");
114
123
  }
115
- ]);
116
- // Re-write privacy to enum
117
- answers.privacy =
118
- common_1.CommonTypes.Privacy[answers.privacy.toUpperCase()];
119
- answers.ref = args.ref;
120
- if (!answers.confirm) {
121
- this.warn("Aborted");
122
- }
123
- else {
124
- try {
124
+ else {
125
125
  core_1.CliUx.ux.action.start(`Updating Agent ${answers.name}`);
126
126
  const agent = await api.updateAgent(answers);
127
127
  await core_1.CliUx.ux.wait(1000);
128
128
  core_1.CliUx.ux.action.stop(agent.ref);
129
129
  }
130
- catch (e) {
131
- core_1.CliUx.ux.action.stop();
132
- throw new errors_1.CLIError(e.message);
133
- }
130
+ }
131
+ catch (e) {
132
+ core_1.CliUx.ux.action.stop();
133
+ throw new errors_1.CLIError(e.message);
134
134
  }
135
135
  }
136
136
  }
@@ -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,61 @@
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.Credentials({ endpoint, insecure });
35
+ try {
36
+ const credentials = await api.getCredentials(args.ref);
37
+ const jsonObj = {
38
+ Ref: credentials.ref,
39
+ APIVersion: credentials.apiVersion,
40
+ Name: credentials.name,
41
+ Username: credentials.username,
42
+ Extended: credentials.extended,
43
+ Created: (0, moment_1.default)(new Date(credentials.createdAt * 1000)).toISOString(),
44
+ Updated: (0, moment_1.default)(new Date(credentials.updatedAt * 1000)).toISOString()
45
+ };
46
+ this.log((0, prettyjson_1.render)(jsonObj, { noColor: true }));
47
+ }
48
+ catch (e) {
49
+ throw new errors_1.CLIError(e.message);
50
+ }
51
+ }
52
+ }
53
+ exports.default = DescribeCommand;
54
+ DescribeCommand.description = "shows details for a set of Credentials";
55
+ DescribeCommand.args = [
56
+ {
57
+ name: "ref",
58
+ required: false,
59
+ description: "reference to the set of Credentials"
60
+ }
61
+ ];
@@ -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);
@@ -63,25 +63,6 @@ class GetCommand extends base_1.BaseCommand {
63
63
  },
64
64
  username: {
65
65
  header: "Username"
66
- },
67
- createdAt: {
68
- header: "Created",
69
- get: (row) => new Date(row.createdAt * 1000),
70
- extended: true
71
- },
72
- updatedAt: {
73
- header: "Updated",
74
- get: (row) => new Date(row.updatedAt * 1000),
75
- extended: true
76
- },
77
- extended: {
78
- header: "Extended",
79
- get: (row) => row.extended || {},
80
- extended: true
81
- },
82
- apiVersion: {
83
- header: "API",
84
- extended: true
85
66
  }
86
67
  }, {
87
68
  "no-header": !showHeader,
@@ -119,6 +100,10 @@ GetCommand.flags = {
119
100
  char: "s",
120
101
  description: "the number of items to return",
121
102
  default: 50
103
+ }),
104
+ extended: core_1.Flags.boolean({
105
+ char: "x",
106
+ description: "extended output format"
122
107
  })
123
108
  };
124
109
  GetCommand.args = [
@@ -34,51 +34,51 @@ class UpdateCommand extends base_1.BaseCommand {
34
34
  async run() {
35
35
  const { args, flags } = await this.parse(UpdateCommand);
36
36
  const { endpoint, insecure } = flags;
37
- const api = new sdk_1.default.Credentials({ endpoint, insecure });
38
- this.log("This utility will help you update an existing set of Credentials.");
39
- this.log("Press ^C at any time to quit.");
40
- const credentialsFromDB = await api.getCredentials(args.ref);
41
- const answers = await inquirer_1.default.prompt([
42
- {
43
- name: "name",
44
- message: "Friendly Name",
45
- type: "input",
46
- default: credentialsFromDB.name,
47
- validate: validators_1.nameValidator
48
- },
49
- {
50
- name: "username",
51
- message: "Username",
52
- type: "input",
53
- default: credentialsFromDB.username,
54
- validate: validators_1.usernameValidator
55
- },
56
- {
57
- name: "password",
58
- message: "Password",
59
- type: "password"
60
- },
61
- {
62
- name: "confirm",
63
- message: "Ready?",
64
- type: "confirm"
37
+ try {
38
+ const api = new sdk_1.default.Credentials({ endpoint, insecure });
39
+ const credentialsFromDB = await api.getCredentials(args.ref);
40
+ this.log("This utility will help you update an existing set of Credentials.");
41
+ this.log("Press ^C at any time to quit.");
42
+ const answers = await inquirer_1.default.prompt([
43
+ {
44
+ name: "name",
45
+ message: "Friendly Name",
46
+ type: "input",
47
+ default: credentialsFromDB.name,
48
+ validate: validators_1.nameValidator
49
+ },
50
+ {
51
+ name: "username",
52
+ message: "Username",
53
+ type: "input",
54
+ default: credentialsFromDB.username,
55
+ validate: validators_1.usernameValidator
56
+ },
57
+ {
58
+ name: "password",
59
+ message: "Password",
60
+ type: "password"
61
+ },
62
+ {
63
+ name: "confirm",
64
+ message: "Ready?",
65
+ type: "confirm"
66
+ }
67
+ ]);
68
+ answers.ref = args.ref;
69
+ if (!answers.confirm) {
70
+ this.warn("Aborted");
65
71
  }
66
- ]);
67
- answers.ref = args.ref;
68
- if (!answers.confirm) {
69
- this.warn("Aborted");
70
- }
71
- else {
72
- try {
72
+ else {
73
73
  core_1.CliUx.ux.action.start(`Updating Credentials for ${answers.name}`);
74
74
  const acl = await api.updateCredentials(answers);
75
75
  await core_1.CliUx.ux.wait(1000);
76
76
  core_1.CliUx.ux.action.stop(acl.ref);
77
77
  }
78
- catch (e) {
79
- core_1.CliUx.ux.action.stop();
80
- throw new errors_1.CLIError(e.message);
81
- }
78
+ }
79
+ catch (e) {
80
+ core_1.CliUx.ux.action.stop();
81
+ throw new errors_1.CLIError(e.message);
82
82
  }
83
83
  }
84
84
  }