@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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @routr/ctl
20
20
  $ rctl COMMAND
21
21
  running command...
22
22
  $ rctl (--version)
23
- @routr/ctl/2.0.8-alpha.23 darwin-x64 node-v16.18.1
23
+ @routr/ctl/2.0.8-alpha.24 darwin-x64 node-v16.18.1
24
24
  $ rctl --help [COMMAND]
25
25
  USAGE
26
26
  $ rctl COMMAND
@@ -59,56 +59,56 @@ class CreateCommand extends base_1.BaseCommand {
59
59
  async run() {
60
60
  const { flags } = await this.parse(CreateCommand);
61
61
  const { endpoint, insecure } = flags;
62
- this.log("This utility will help you create a new ACL");
63
- this.log("Press ^C at any time to quit.");
64
- const answers = await inquirer_1.default.prompt([
65
- {
66
- name: "name",
67
- message: "Friendly Name",
68
- type: "input",
69
- validate: validators_1.nameValidator
70
- },
71
- {
72
- name: "deny",
73
- message: "Deny CIDR Networks",
74
- type: "input",
75
- default: "0.0.0.0/0",
76
- validate: validators_1.aclRuleValidator
77
- },
78
- {
79
- name: "allow",
80
- message: "Allow CIDR Networks",
81
- type: "input",
82
- validate: validators_1.aclRuleValidator
83
- },
84
- {
85
- name: "confirm",
86
- message: "Ready?",
87
- type: "confirm"
62
+ try {
63
+ this.log("This utility will help you create a new ACL");
64
+ this.log("Press ^C at any time to quit.");
65
+ const answers = await inquirer_1.default.prompt([
66
+ {
67
+ name: "name",
68
+ message: "Friendly Name",
69
+ type: "input",
70
+ validate: validators_1.nameValidator
71
+ },
72
+ {
73
+ name: "deny",
74
+ message: "Deny CIDR Networks",
75
+ type: "input",
76
+ default: "0.0.0.0/0",
77
+ validate: validators_1.aclRuleValidator
78
+ },
79
+ {
80
+ name: "allow",
81
+ message: "Allow CIDR Networks",
82
+ type: "input",
83
+ validate: validators_1.aclRuleValidator
84
+ },
85
+ {
86
+ name: "confirm",
87
+ message: "Ready?",
88
+ type: "confirm"
89
+ }
90
+ ]);
91
+ // Re-assign allow and deny rules as arrays
92
+ answers.allow = (0, utils_1.stringToACL)(answers.allow);
93
+ answers.deny = (0, utils_1.stringToACL)(answers.deny);
94
+ if (!answers.confirm) {
95
+ this.warn("Aborted");
88
96
  }
89
- ]);
90
- // Re-assign allow and deny rules as arrays
91
- answers.allow = (0, utils_1.stringToACL)(answers.allow);
92
- answers.deny = (0, utils_1.stringToACL)(answers.deny);
93
- if (!answers.confirm) {
94
- this.warn("Aborted");
95
- }
96
- else {
97
- try {
97
+ else {
98
98
  core_1.CliUx.ux.action.start(`Creating ACL ${answers.name}`);
99
99
  const api = new sdk_1.default.ACL({ endpoint, insecure });
100
100
  const acl = await api.createACL(answers);
101
101
  await core_1.CliUx.ux.wait(1000);
102
102
  core_1.CliUx.ux.action.stop(acl.ref);
103
103
  }
104
- catch (e) {
105
- core_1.CliUx.ux.action.stop();
106
- if (e.code === grpc.status.ALREADY_EXISTS) {
107
- throw new errors_1.CLIError("This ACL already exist");
108
- }
109
- else {
110
- throw new errors_1.CLIError(e.message);
111
- }
104
+ }
105
+ catch (e) {
106
+ core_1.CliUx.ux.action.stop();
107
+ if (e.code === grpc.status.ALREADY_EXISTS) {
108
+ throw new errors_1.CLIError("This ACL already exist");
109
+ }
110
+ else {
111
+ throw new errors_1.CLIError(e.message);
112
112
  }
113
113
  }
114
114
  }
@@ -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);
@@ -36,55 +36,55 @@ 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.ACL({ endpoint, insecure });
39
- this.log("This utility will help you update an existing ACL.");
40
- this.log("Press ^C at any time to quit.");
41
- const aclFromDB = await api.getACL(args.ref);
42
- const answers = await inquirer_1.default.prompt([
43
- {
44
- name: "name",
45
- message: "Friendly Name",
46
- type: "input",
47
- default: aclFromDB.name,
48
- validate: validators_1.nameValidator
49
- },
50
- {
51
- name: "deny",
52
- message: "Deny CIDR Networks",
53
- type: "input",
54
- default: aclFromDB.deny.join(","),
55
- validate: validators_1.aclRuleValidator
56
- },
57
- {
58
- name: "allow",
59
- message: "Allow CIDR Networks",
60
- type: "input",
61
- default: aclFromDB.allow.join(","),
62
- validate: validators_1.aclRuleValidator
63
- },
64
- {
65
- name: "confirm",
66
- message: "Ready?",
67
- type: "confirm"
39
+ try {
40
+ const aclFromDB = await api.getACL(args.ref);
41
+ this.log("This utility will help you update an existing ACL.");
42
+ this.log("Press ^C at any time to quit.");
43
+ const answers = await inquirer_1.default.prompt([
44
+ {
45
+ name: "name",
46
+ message: "Friendly Name",
47
+ type: "input",
48
+ default: aclFromDB.name,
49
+ validate: validators_1.nameValidator
50
+ },
51
+ {
52
+ name: "deny",
53
+ message: "Deny CIDR Networks",
54
+ type: "input",
55
+ default: aclFromDB.deny.join(","),
56
+ validate: validators_1.aclRuleValidator
57
+ },
58
+ {
59
+ name: "allow",
60
+ message: "Allow CIDR Networks",
61
+ type: "input",
62
+ default: aclFromDB.allow.join(","),
63
+ validate: validators_1.aclRuleValidator
64
+ },
65
+ {
66
+ name: "confirm",
67
+ message: "Ready?",
68
+ type: "confirm"
69
+ }
70
+ ]);
71
+ answers.ref = args.ref;
72
+ // Re-assign allow and deny rules as arrays
73
+ answers.allow = (0, utils_1.stringToACL)(answers.allow);
74
+ answers.deny = (0, utils_1.stringToACL)(answers.deny);
75
+ if (!answers.confirm) {
76
+ this.warn("Aborted");
68
77
  }
69
- ]);
70
- answers.ref = args.ref;
71
- // Re-assign allow and deny rules as arrays
72
- answers.allow = (0, utils_1.stringToACL)(answers.allow);
73
- answers.deny = (0, utils_1.stringToACL)(answers.deny);
74
- if (!answers.confirm) {
75
- this.warn("Aborted");
76
- }
77
- else {
78
- try {
78
+ else {
79
79
  core_1.CliUx.ux.action.start(`Updating ACL ${answers.name}`);
80
80
  const acl = await api.updateACL(answers);
81
81
  await core_1.CliUx.ux.wait(1000);
82
82
  core_1.CliUx.ux.action.stop(acl.ref);
83
83
  }
84
- catch (e) {
85
- core_1.CliUx.ux.action.stop();
86
- throw new errors_1.CLIError(e.message);
87
- }
84
+ }
85
+ catch (e) {
86
+ core_1.CliUx.ux.action.stop();
87
+ throw new errors_1.CLIError(e.message);
88
88
  }
89
89
  }
90
90
  }
@@ -62,110 +62,110 @@ class CreateAgentCommand extends base_1.BaseCommand {
62
62
  async run() {
63
63
  const { flags } = await this.parse(CreateAgentCommand);
64
64
  const { endpoint, insecure } = flags;
65
- this.log("This utility will help you create a new Agent.");
66
- this.log("Press ^C at any time to quit.");
67
- // TODO: Fix hardcoded pageSize
68
- const domains = await new sdk_1.default.Domains({ endpoint, insecure }).listDomains({
69
- pageSize: 25,
70
- pageToken: ""
71
- });
72
- // TODO: Fix hardcoded pageSize
73
- const credentials = await new sdk_1.default.Credentials({
74
- endpoint,
75
- insecure
76
- }).listCredentials({
77
- pageSize: 25,
78
- pageToken: ""
79
- });
80
- const domainsList = domains.items.map((domain) => {
81
- return {
82
- name: domain.domainUri,
83
- description: domain.name,
84
- value: domain.ref
85
- };
86
- });
87
- const credentialsList = credentials.items.map((credential) => {
88
- return { name: credential.name, value: credential.ref };
89
- });
90
- const searcher = new fuzzy_search_1.default(domainsList, ["name", "value", "description"], {
91
- caseSensitive: false
92
- });
93
- const answers = await inquirer_1.default.prompt([
94
- {
95
- name: "name",
96
- message: "Friendly Name",
97
- type: "input",
98
- validate: validators_1.nameValidator
99
- },
100
- {
101
- type: "autocomplete",
102
- name: "domainRef",
103
- message: "Select a Domain",
104
- source: (_, input) => searcher.search(input),
105
- when: () => domains.items.length > 0
106
- },
107
- {
108
- name: "username",
109
- message: "Username",
110
- type: "input",
111
- validate: validators_1.usernameValidator
112
- },
113
- {
114
- name: "credentialsRef",
115
- message: "Credentials Name",
116
- type: "list",
117
- choices: [{ name: "None", value: undefined }, ...credentialsList]
118
- },
119
- {
120
- name: "privacy",
121
- message: "Privacy",
122
- type: "list",
123
- choices: [
124
- {
125
- name: "None",
126
- value: common_1.CommonTypes.Privacy.NONE
127
- },
128
- {
129
- name: "Private",
130
- value: common_1.CommonTypes.Privacy.PRIVATE
131
- }
132
- ],
133
- default: common_1.CommonTypes.Privacy.NONE
134
- },
135
- {
136
- name: "enabled",
137
- message: "Enabled",
138
- type: "confirm",
139
- default: true
140
- },
141
- {
142
- name: "confirm",
143
- message: "Ready?",
144
- type: "confirm"
65
+ try {
66
+ // TODO: Fix hardcoded pageSize
67
+ const domains = await new sdk_1.default.Domains({ endpoint, insecure }).listDomains({
68
+ pageSize: 25,
69
+ pageToken: ""
70
+ });
71
+ // TODO: Fix hardcoded pageSize
72
+ const credentials = await new sdk_1.default.Credentials({
73
+ endpoint,
74
+ insecure
75
+ }).listCredentials({
76
+ pageSize: 25,
77
+ pageToken: ""
78
+ });
79
+ const domainsList = domains.items.map((domain) => {
80
+ return {
81
+ name: domain.domainUri,
82
+ description: domain.name,
83
+ value: domain.ref
84
+ };
85
+ });
86
+ const credentialsList = credentials.items.map((credential) => {
87
+ return { name: credential.name, value: credential.ref };
88
+ });
89
+ const searcher = new fuzzy_search_1.default(domainsList, ["name", "value", "description"], {
90
+ caseSensitive: false
91
+ });
92
+ this.log("This utility will help you create a new Agent.");
93
+ this.log("Press ^C at any time to quit.");
94
+ const answers = await inquirer_1.default.prompt([
95
+ {
96
+ name: "name",
97
+ message: "Friendly Name",
98
+ type: "input",
99
+ validate: validators_1.nameValidator
100
+ },
101
+ {
102
+ type: "autocomplete",
103
+ name: "domainRef",
104
+ message: "Select a Domain",
105
+ source: (_, input) => searcher.search(input),
106
+ when: () => domains.items.length > 0
107
+ },
108
+ {
109
+ name: "username",
110
+ message: "Username",
111
+ type: "input",
112
+ validate: validators_1.usernameValidator
113
+ },
114
+ {
115
+ name: "credentialsRef",
116
+ message: "Credentials Name",
117
+ type: "list",
118
+ choices: [{ name: "None", value: undefined }, ...credentialsList]
119
+ },
120
+ {
121
+ name: "privacy",
122
+ message: "Privacy",
123
+ type: "list",
124
+ choices: [
125
+ {
126
+ name: "None",
127
+ value: common_1.CommonTypes.Privacy.NONE
128
+ },
129
+ {
130
+ name: "Private",
131
+ value: common_1.CommonTypes.Privacy.PRIVATE
132
+ }
133
+ ],
134
+ default: common_1.CommonTypes.Privacy.NONE
135
+ },
136
+ {
137
+ name: "enabled",
138
+ message: "Enabled",
139
+ type: "confirm",
140
+ default: true
141
+ },
142
+ {
143
+ name: "confirm",
144
+ message: "Ready?",
145
+ type: "confirm"
146
+ }
147
+ ]);
148
+ // Re-write privacy to enum
149
+ answers.privacy =
150
+ common_1.CommonTypes.Privacy[answers.privacy.toUpperCase()];
151
+ if (!answers.confirm) {
152
+ this.warn("Aborted");
145
153
  }
146
- ]);
147
- // Re-write privacy to enum
148
- answers.privacy =
149
- common_1.CommonTypes.Privacy[answers.privacy.toUpperCase()];
150
- if (!answers.confirm) {
151
- this.warn("Aborted");
152
- }
153
- else {
154
- try {
154
+ else {
155
155
  core_1.CliUx.ux.action.start(`Creating Agent ${answers.name}`);
156
156
  const api = new sdk_1.default.Agents({ endpoint, insecure });
157
157
  const agent = await api.createAgent(answers);
158
158
  await core_1.CliUx.ux.wait(1000);
159
159
  core_1.CliUx.ux.action.stop(agent.ref);
160
160
  }
161
- catch (e) {
162
- core_1.CliUx.ux.action.stop();
163
- if (e.code === grpc.status.ALREADY_EXISTS) {
164
- throw new errors_1.CLIError("This Agent already exist");
165
- }
166
- else {
167
- throw new errors_1.CLIError(e.message);
168
- }
161
+ }
162
+ catch (e) {
163
+ core_1.CliUx.ux.action.stop();
164
+ if (e.code === grpc.status.ALREADY_EXISTS) {
165
+ throw new errors_1.CLIError("This Agent already exist");
166
+ }
167
+ else {
168
+ throw new errors_1.CLIError(e.message);
169
169
  }
170
170
  }
171
171
  }
@@ -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
  }