@codiac.io/codiac-cli 1.3.83 → 1.3.85

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 (96) hide show
  1. package/README.md +1 -1
  2. package/dist/apis/codiac-api-nats/gen/client.d.ts +4 -4
  3. package/dist/apis/codiac-api-nats/gen/client.js +72 -54
  4. package/dist/apis/codiac-api-nats/gen/client.js.map +1 -1
  5. package/dist/command-base-enterprise.d.ts +5 -0
  6. package/dist/command-base-enterprise.js +23 -7
  7. package/dist/command-base-enterprise.js.map +1 -1
  8. package/dist/command-base-exec-tenant.js +8 -2
  9. package/dist/command-base-exec-tenant.js.map +1 -1
  10. package/dist/command-base-exec.js +8 -2
  11. package/dist/command-base-exec.js.map +1 -1
  12. package/dist/commands/asset/list.js +3 -0
  13. package/dist/commands/asset/list.js.map +1 -1
  14. package/dist/commands/asset/probe/create.js +4 -0
  15. package/dist/commands/asset/probe/create.js.map +1 -1
  16. package/dist/commands/asset/recycle.js +3 -0
  17. package/dist/commands/asset/recycle.js.map +1 -1
  18. package/dist/commands/asset/undeploy.js +7 -0
  19. package/dist/commands/asset/undeploy.js.map +1 -1
  20. package/dist/commands/asset/view.js +5 -2
  21. package/dist/commands/asset/view.js.map +1 -1
  22. package/dist/commands/asset/volume/create.js +107 -98
  23. package/dist/commands/asset/volume/create.js.map +1 -1
  24. package/dist/commands/asset/volume/delete.js +50 -41
  25. package/dist/commands/asset/volume/delete.js.map +1 -1
  26. package/dist/commands/asset/volume/list.js +23 -14
  27. package/dist/commands/asset/volume/list.js.map +1 -1
  28. package/dist/commands/cabinet/list.js +4 -2
  29. package/dist/commands/cabinet/list.js.map +1 -1
  30. package/dist/commands/config/add.js +5 -0
  31. package/dist/commands/config/add.js.map +1 -1
  32. package/dist/commands/config/delete.js +4 -0
  33. package/dist/commands/config/delete.js.map +1 -1
  34. package/dist/commands/config/deploy.js +4 -0
  35. package/dist/commands/config/deploy.js.map +1 -1
  36. package/dist/commands/config/import.js +108 -98
  37. package/dist/commands/config/import.js.map +1 -1
  38. package/dist/commands/config/settings/get.js +4 -0
  39. package/dist/commands/config/settings/get.js.map +1 -1
  40. package/dist/commands/config/view.js +72 -59
  41. package/dist/commands/config/view.js.map +1 -1
  42. package/dist/commands/csp/login.js +6 -0
  43. package/dist/commands/csp/login.js.map +1 -1
  44. package/dist/commands/csp/logout.js +3 -0
  45. package/dist/commands/csp/logout.js.map +1 -1
  46. package/dist/commands/deploy.js +3 -0
  47. package/dist/commands/deploy.js.map +1 -1
  48. package/dist/commands/enterprise/list.js +5 -1
  49. package/dist/commands/enterprise/list.js.map +1 -1
  50. package/dist/commands/env/add.js +107 -97
  51. package/dist/commands/env/add.js.map +1 -1
  52. package/dist/commands/environment/list.js +5 -2
  53. package/dist/commands/environment/list.js.map +1 -1
  54. package/dist/commands/host/map.js +97 -87
  55. package/dist/commands/host/map.js.map +1 -1
  56. package/dist/commands/imageRegistry/capture.js +4 -3
  57. package/dist/commands/imageRegistry/capture.js.map +1 -1
  58. package/dist/commands/imageRegistry/forget.js +4 -3
  59. package/dist/commands/imageRegistry/forget.js.map +1 -1
  60. package/dist/commands/imageRegistry/pullSecret/set.js +4 -3
  61. package/dist/commands/imageRegistry/pullSecret/set.js.map +1 -1
  62. package/dist/commands/imageRegistry/pullSecret/unset.js +4 -3
  63. package/dist/commands/imageRegistry/pullSecret/unset.js.map +1 -1
  64. package/dist/commands/images/add.js +37 -28
  65. package/dist/commands/images/add.js.map +1 -1
  66. package/dist/commands/kit/create.js +3 -2
  67. package/dist/commands/kit/create.js.map +1 -1
  68. package/dist/commands/login.js +3 -0
  69. package/dist/commands/login.js.map +1 -1
  70. package/dist/commands/logout.js +3 -0
  71. package/dist/commands/logout.js.map +1 -1
  72. package/dist/commands/noc/cluster/deinit.js +9 -3
  73. package/dist/commands/noc/cluster/deinit.js.map +1 -1
  74. package/dist/commands/noc/cluster/grant.js +61 -49
  75. package/dist/commands/noc/cluster/grant.js.map +1 -1
  76. package/dist/commands/noc/cluster/init.js +9 -3
  77. package/dist/commands/noc/cluster/init.js.map +1 -1
  78. package/dist/commands/noc/cluster/list.js +5 -2
  79. package/dist/commands/noc/cluster/list.js.map +1 -1
  80. package/dist/commands/noc/cluster/recreate.js +24 -14
  81. package/dist/commands/noc/cluster/recreate.js.map +1 -1
  82. package/dist/commands/portal.js +3 -0
  83. package/dist/commands/portal.js.map +1 -1
  84. package/dist/commands/secretStore/capture.js +35 -36
  85. package/dist/commands/secretStore/capture.js.map +1 -1
  86. package/dist/commands/secretStore/forget.js +32 -33
  87. package/dist/commands/secretStore/forget.js.map +1 -1
  88. package/dist/commands/tenant/create.js +34 -32
  89. package/dist/commands/tenant/create.js.map +1 -1
  90. package/dist/commands/tenant/switch.js +30 -34
  91. package/dist/commands/tenant/switch.js.map +1 -1
  92. package/dist/commands/whereami.js +3 -0
  93. package/dist/commands/whereami.js.map +1 -1
  94. package/dist/relay/relay-container.js +1 -1
  95. package/oclif.manifest.json +1 -1
  96. package/package.json +2 -2
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @codiac.io/codiac-cli
21
21
  $ codiac COMMAND
22
22
  running command...
23
23
  $ codiac (--version|-v)
24
- @codiac.io/codiac-cli/1.3.83 linux-x64 node-v16.17.1
24
+ @codiac.io/codiac-cli/1.3.85 linux-x64 node-v16.17.1
25
25
  $ codiac --help [COMMAND]
26
26
  USAGE
27
27
  $ codiac COMMAND
@@ -2540,10 +2540,10 @@ declare class OtherOperations {
2540
2540
  /** Shows the cabinets to which the given asset is currently deployed and which version is where. */
2541
2541
  assetWhere(request: Contracts.AssetWhereRequest, options?: IRepoOptions): Promise<ListResult<Contracts.CabinetAssetVersion>>;
2542
2542
  /** Retrieves the enterprise configuration currently in play in a single given cabinet,
2543
- in terms of versions of the enterprise and its assets.
2544
- This is a composite/hybrid object made up of a Cabinet, EnterpriseVersionConfig and an EnterpriseRunState.
2545
- Compares versions of each asset between the version specified in the assigned enterprise version config
2546
- and the version that is actually physically running in the cabinet. */
2543
+ in terms of versions of the enterprise and its assets.
2544
+ This is a composite/hybrid object made up of a Cabinet, EnterpriseVersionConfig and an EnterpriseRunState.
2545
+ Compares versions of each asset between the version specified in the assigned enterprise version config
2546
+ and the version that is actually physically running in the cabinet. */
2547
2547
  getCabinetConfigState(request: Contracts.CabinetConfigStateRequest, options?: IRepoOptions): Promise<Contracts.CabinetConfigState>;
2548
2548
  /** Retrieves all available enterprises, environments, cabinets, and clusters for the given tenant. */
2549
2549
  getCabinetScopes(request: Contracts.CabinetScopesCriteria, options?: IRepoOptions): Promise<ListResult<Contracts.EnterpriseScope>>;
@@ -133,35 +133,42 @@ let CodiacNatsClient = CodiacNatsClient_1 = class CodiacNatsClient {
133
133
  }
134
134
  }
135
135
  connect() {
136
- var _a, _b, _c;
137
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
138
- const codiacJwt = (_a = this._tokenCredentials) === null || _a === void 0 ? void 0 : _a.jwtToken;
139
- if (codiacJwt == undefined) {
140
- throw new Error("No token client available.");
141
- }
142
- const payload = (_b = new jwt.JwtEncoder().tryDecode(codiacJwt)) === null || _b === void 0 ? void 0 : _b.payload;
143
- if (payload == undefined)
144
- throw new Error("Empty jwt payload");
145
- const gck = payload[CodiacNatsClient_1.CLAIM_FOR_GLOBAL_CLIENT_KEY];
146
- if (gck == undefined)
147
- throw new Error("No global client key was available in the token payload.");
148
- const natsCreds = buffer_1.Buffer.from(gck, 'base64').toString('utf-8');
149
- const opts = {
150
- servers: this.settings.baseUrl,
151
- authenticator: [
152
- Nats.tokenAuthenticator(codiacJwt),
153
- Nats.credsAuthenticator(new TextEncoder().encode(natsCreds))
154
- ],
155
- verbose: true
156
- };
157
- if (this.clientType === "websockets") {
158
- CodiacNatsClient_1._nc = yield Nats.wsconnect(opts);
136
+ var _a, _b, _c, _d;
137
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
138
+ try {
139
+ // Assemble authenticator from codiac jwt
140
+ const codiacJwt = (_a = this._tokenCredentials) === null || _a === void 0 ? void 0 : _a.jwtToken;
141
+ if (codiacJwt == undefined) {
142
+ throw new Error("No token client available.");
143
+ }
144
+ const payload = (_b = new jwt.JwtEncoder().tryDecode(codiacJwt)) === null || _b === void 0 ? void 0 : _b.payload;
145
+ if (payload == undefined)
146
+ throw new Error("Empty jwt payload");
147
+ const gck = payload[CodiacNatsClient_1.CLAIM_FOR_GLOBAL_CLIENT_KEY];
148
+ if (gck == undefined)
149
+ throw new Error("No global client key was available in the token payload.");
150
+ const natsCreds = buffer_1.Buffer.from(gck, 'base64').toString('utf-8');
151
+ const opts = {
152
+ servers: this.settings.baseUrl,
153
+ authenticator: [
154
+ Nats.tokenAuthenticator(codiacJwt),
155
+ Nats.credsAuthenticator(new TextEncoder().encode(natsCreds))
156
+ ],
157
+ verbose: true
158
+ };
159
+ if (this.clientType === "websockets") {
160
+ CodiacNatsClient_1._nc = yield Nats.wsconnect(opts);
161
+ }
162
+ else {
163
+ CodiacNatsClient_1._nc = yield Transport.connect(opts);
164
+ }
165
+ this.logger.write(`Connected to ${this.settings.baseUrl}`);
166
+ return (_c = CodiacNatsClient_1.nc) === null || _c === void 0 ? void 0 : _c.info;
159
167
  }
160
- else {
161
- CodiacNatsClient_1._nc = yield Transport.connect(opts);
168
+ catch (err) {
169
+ this.logger.error((_d = err.message) !== null && _d !== void 0 ? _d : "Error connecting to nats: (no error message available)");
170
+ throw err;
162
171
  }
163
- this.logger.write(`Connected to ${this.settings.baseUrl}`);
164
- return (_c = CodiacNatsClient_1.nc) === null || _c === void 0 ? void 0 : _c.info;
165
172
  });
166
173
  }
167
174
  isConnected() {
@@ -200,7 +207,7 @@ let CodiacNatsClient = CodiacNatsClient_1 = class CodiacNatsClient {
200
207
  // const values = isGet ? this.getValues(req) : { ...req };
201
208
  const loadedSubject = Utils.hydrateSubjectParams(subject, req);
202
209
  const headers = options ? Utils.headersFrom(options) : undefined;
203
- return this.makeRequest(loadedSubject, req, headers);
210
+ return yield this.makeRequest(loadedSubject, req, headers);
204
211
  }
205
212
  catch (error) {
206
213
  if (noThrow) {
@@ -213,31 +220,42 @@ let CodiacNatsClient = CodiacNatsClient_1 = class CodiacNatsClient {
213
220
  }
214
221
  makeRequest(subject, req, headers) {
215
222
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
216
- return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
217
- try {
218
- // this.logger.detail(`Api client making request: ${httpVerb} ${url?.split("?")[0]}`);
219
- let reqHeaders = Nats.headers();
220
- reqHeaders.append("content-type", "application/json");
221
- if (this.tokenCredentials) {
222
- reqHeaders.append(CodiacNatsClient_1.DEFAULT_TOKEN_HEADER_PARAM, this.tokenCredentials.jwtToken);
223
- }
224
- if (headers) {
225
- for (let headerKey in headers) {
226
- if (headers[headerKey])
227
- reqHeaders.append(headerKey, headers[headerKey]);
228
- }
223
+ // return new Promise<TResponse>(async (resolve, reject) => {
224
+ try {
225
+ // this.logger.detail(`Api client making request: ${httpVerb} ${url?.split("?")[0]}`);
226
+ let reqHeaders = Nats.headers();
227
+ reqHeaders.append("content-type", "application/json");
228
+ if (this.tokenCredentials) {
229
+ reqHeaders.append(CodiacNatsClient_1.DEFAULT_TOKEN_HEADER_PARAM, this.tokenCredentials.jwtToken);
230
+ }
231
+ if (headers) {
232
+ for (let headerKey in headers) {
233
+ if (headers[headerKey])
234
+ reqHeaders.append(headerKey, headers[headerKey]);
229
235
  }
230
- if (!this.isConnected())
231
- yield this.connect();
232
- const res = yield CodiacNatsClient_1.nc.request(subject, JSON.stringify(req), { headers: reqHeaders, timeout: 5000 });
233
- resolve(res.json());
234
236
  }
235
- catch (err) {
236
- this.logger.error(`Error making call: ${err.message}`, { subject: subject, error: err });
237
- this.logger.debug(err);
238
- reject(err);
237
+ /** Determines whether a connection needs to be
238
+ * opened (and closed) just for this request. */
239
+ // let disconnectNow = false;
240
+ if (!this.isConnected()) {
241
+ yield this.connect();
242
+ // disconnectNow = true;
239
243
  }
240
- }));
244
+ const res = yield CodiacNatsClient_1.nc.request(subject, JSON.stringify(req), { headers: reqHeaders, timeout: 5000 });
245
+ let output = res.json();
246
+ // COMMENTED OUT BC: disconnect() needs to get invoked from the caller so that it can stay open for many executions.
247
+ // We could build some config to enable different connection paradigms, but its not necessary at the moment.
248
+ // if (disconnectNow) {
249
+ // await this.disconnect();
250
+ // }
251
+ return output;
252
+ }
253
+ catch (err) {
254
+ this.logger.error(`Error making call: ${err.message}`, { subject: subject, error: err });
255
+ this.logger.debug(err);
256
+ throw (err);
257
+ }
258
+ // });
241
259
  });
242
260
  }
243
261
  }; // end class CodiacNatsClient
@@ -15693,10 +15711,10 @@ class OtherOperations {
15693
15711
  });
15694
15712
  }
15695
15713
  /** Retrieves the enterprise configuration currently in play in a single given cabinet,
15696
- in terms of versions of the enterprise and its assets.
15697
- This is a composite/hybrid object made up of a Cabinet, EnterpriseVersionConfig and an EnterpriseRunState.
15698
- Compares versions of each asset between the version specified in the assigned enterprise version config
15699
- and the version that is actually physically running in the cabinet. */
15714
+ in terms of versions of the enterprise and its assets.
15715
+ This is a composite/hybrid object made up of a Cabinet, EnterpriseVersionConfig and an EnterpriseRunState.
15716
+ Compares versions of each asset between the version specified in the assigned enterprise version config
15717
+ and the version that is actually physically running in the cabinet. */
15700
15718
  getCabinetConfigState(request, options) {
15701
15719
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
15702
15720
  return yield this.core.request("get.enterprise.:enterprise.cabinet.:cabinet.config-state", request, options);