@zowe/core-for-zowe-sdk 7.16.4 → 7.17.0

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.
@@ -50,46 +50,110 @@ class ZosmfRestClient extends imperative_1.RestClient {
50
50
  * @memberof ZosmfRestClient
51
51
  */
52
52
  processError(original) {
53
- original.msg = "z/OSMF REST API Error:\n" + original.msg;
54
- let details = original.causeErrors;
53
+ var _a, _b;
54
+ // TODO:V3_ERR_FORMAT - Remove block in V3
55
+ if (!imperative_1.NextVerFeatures.useV3ErrFormat()) {
56
+ original.msg = "z/OSMF REST API Error:\n" + original.msg;
57
+ }
58
+ let causeErrorsJson;
59
+ let causeErrorsString = "";
60
+ if (original.causeErrors) {
61
+ causeErrorsString = original.causeErrors;
62
+ }
55
63
  try {
56
- const json = JSON.parse(details);
57
- // if we didn't get an error trying to parse json, check if there is a stack
58
- // on the JSON error and delete it
59
- if (json.stack != null) {
60
- this.log.error("An error was encountered in z/OSMF with a stack." +
61
- " Here is the full error before deleting the stack:\n%s", JSON.stringify(json));
62
- this.log.error("The stack has been deleted from the error before displaying the error to the user");
63
- delete json.stack; // remove the stack field
64
+ // don't try to parse an empty string
65
+ if (causeErrorsString !== "") {
66
+ causeErrorsJson = JSON.parse(causeErrorsString);
67
+ // if we didn't get an error trying to parse causeErrorsString, check if there is a stack
68
+ // on the JSON error and delete it
69
+ if (causeErrorsJson.stack != null) {
70
+ this.log.error("An error was encountered in z/OSMF with a stack." +
71
+ " Here is the full error before deleting the stack:\n%s", JSON.stringify(causeErrorsJson));
72
+ this.log.error("The stack has been deleted from the error before displaying the error to the user");
73
+ delete causeErrorsJson.stack; // remove the stack field
74
+ }
75
+ // if we didn't get an error, make the parsed causeErrorsString part of the error
76
+ causeErrorsString = imperative_1.TextUtils.prettyJson(causeErrorsJson, undefined, false);
64
77
  }
65
- // if we didn't get an error, make the parsed details part of the error
66
- details = imperative_1.TextUtils.prettyJson(json, undefined, false);
67
78
  }
68
79
  catch (e) {
69
- // if there's an error, the causeErrors text is not json
80
+ // if there's an error, the causeErrors text is not JSON
70
81
  this.log.debug("Encountered an error trying to parse causeErrors as JSON - causeErrors is likely not JSON format");
71
82
  }
72
- original.msg += "\n" + details; // add the data string which is the original error
73
- if (this.response && this.response.statusCode === imperative_1.RestConstants.HTTP_STATUS_401) {
74
- original.msg = "This operation requires authentication.\n\n" + original.msg +
75
- "\nHost: " + this.session.ISession.hostname +
76
- "\nPort: " + this.session.ISession.port +
77
- "\nBase Path: " + this.session.ISession.basePath +
78
- "\nResource: " + this.mResource +
79
- "\nRequest: " + this.mRequest +
80
- "\nHeaders: " + JSON.stringify(this.mReqHeaders) +
81
- "\nPayload: " + this.mRequest +
82
- "\n";
83
- if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_BASIC) {
84
- original.additionalDetails = "Username or password are not valid or expired.\n\n";
83
+ const origMsgFor401 = original.msg;
84
+ // TODO:V3_ERR_FORMAT - Don't test for env variable in V3
85
+ if (imperative_1.NextVerFeatures.useV3ErrFormat()) {
86
+ // extract properties from causeErrors and place them into 'msg' as user-focused messages
87
+ if (((_a = causeErrorsJson === null || causeErrorsJson === void 0 ? void 0 : causeErrorsJson.details) === null || _a === void 0 ? void 0 : _a.length) > 0) {
88
+ for (const detail of causeErrorsJson.details) {
89
+ original.msg += "\n" + detail;
90
+ }
91
+ }
92
+ if (((_b = causeErrorsJson === null || causeErrorsJson === void 0 ? void 0 : causeErrorsJson.messages) === null || _b === void 0 ? void 0 : _b.length) > 0) {
93
+ for (const message of causeErrorsJson.messages) {
94
+ original.msg += "\n" + message.messageContent;
95
+ }
85
96
  }
86
- if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_TOKEN) {
87
- original.additionalDetails = "Token is not valid or expired.\n\n" +
88
- "For CLI usage, see `zowe auth login apiml --help`";
97
+ }
98
+ else { // TODO:V3_ERR_FORMAT - Remove in V3
99
+ original.msg += "\n" + causeErrorsString; // add the data string which is the original error
100
+ }
101
+ // add further clarification on authentication errors
102
+ if (this.response && this.response.statusCode === imperative_1.RestConstants.HTTP_STATUS_401) {
103
+ // TODO:V3_ERR_FORMAT - Don't test for env variable in V3
104
+ if (imperative_1.NextVerFeatures.useV3ErrFormat()) {
105
+ if (!original.causeErrors || Object.keys(original.causeErrors).length === 0) {
106
+ /* We have no causeErrors, so place the original msg we got for a 401
107
+ * into the 'response from service' part of our error.
108
+ */
109
+ original.causeErrors = `{"Error": "${origMsgFor401}"}`;
110
+ }
111
+ original.msg += "\nThis operation requires authentication.";
112
+ if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_BASIC) {
113
+ original.msg += "\nUsername or password are not valid or expired.";
114
+ }
115
+ else if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_TOKEN) {
116
+ if (this.session.ISession.tokenType === imperative_1.SessConstants.TOKEN_TYPE_APIML && !this.session.ISession.basePath) {
117
+ original.msg += `\nToken type "${imperative_1.SessConstants.TOKEN_TYPE_APIML}" requires base path to be defined.\n` +
118
+ "You must either connect with username and password or provide a base path.";
119
+ }
120
+ else {
121
+ original.msg += "\nToken is not valid or expired.\n" +
122
+ "For CLI usage, see `zowe auth login apiml --help`";
123
+ }
124
+ // TODO: Add PFX support in the future
125
+ }
126
+ else if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_CERT_PEM) {
127
+ original.msg += "\nCertificate is not valid or expired.";
128
+ }
89
129
  }
90
- // TODO: Add PFX support in the future
91
- if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_CERT_PEM) {
92
- original.additionalDetails = "Certificate is not valid or expired.\n\n";
130
+ else { // TODO:V3_ERR_FORMAT - Remove in V3
131
+ original.msg = "This operation requires authentication.\n\n" + original.msg +
132
+ "\nHost: " + this.session.ISession.hostname +
133
+ "\nPort: " + this.session.ISession.port +
134
+ "\nBase Path: " + this.session.ISession.basePath +
135
+ "\nResource: " + this.mResource +
136
+ "\nRequest: " + this.mRequest +
137
+ "\nHeaders: " + JSON.stringify(this.mReqHeaders) +
138
+ "\nPayload: " + this.mRequest +
139
+ "\n";
140
+ if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_BASIC) {
141
+ original.additionalDetails = "Username or password are not valid or expired.\n\n";
142
+ }
143
+ else if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_TOKEN) {
144
+ if (this.session.ISession.tokenType === imperative_1.SessConstants.TOKEN_TYPE_APIML && !this.session.ISession.basePath) {
145
+ original.additionalDetails = `Token type "${imperative_1.SessConstants.TOKEN_TYPE_APIML}" requires base path to be defined.\n\n` +
146
+ "You must either connect with username and password or provide a base path.";
147
+ }
148
+ else {
149
+ original.additionalDetails = "Token is not valid or expired.\n\n" +
150
+ "For CLI usage, see `zowe auth login apiml --help`";
151
+ }
152
+ // TODO: Add PFX support in the future
153
+ }
154
+ else if (this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_CERT_PEM) {
155
+ original.additionalDetails = "Certificate is not valid or expired.\n\n";
156
+ }
93
157
  }
94
158
  }
95
159
  return original;
@@ -1 +1 @@
1
- {"version":3,"file":"ZosmfRestClient.js","sourceRoot":"","sources":["../../src/rest/ZosmfRestClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;EASE;;;AAEF,iDAAiH;AACjH,iDAA8C;AAE9C;;;;;;GAMG;AACH,MAAa,eAAgB,SAAQ,uBAAU;IAE3C;;;OAGG;IACH,IAAW,GAAG;QACV,OAAO,mBAAM,CAAC,YAAY,EAAE,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACO,aAAa,CAAC,OAA0B;QAC9C,IAAI,OAAO,IAAI,IAAI,EAAE;YACjB,OAAO,GAAG,CAAC,2BAAY,CAAC,mBAAmB,CAAC,CAAC;SAChD;aAAM;YACH,OAAO,CAAC,IAAI,CAAC,2BAAY,CAAC,mBAAmB,CAAC,CAAC;SAClD;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACO,YAAY,CAAC,QAA0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BAAiB,GAAG,eAAe,0BAAa,CAAC,gBAAgB,yCAAyC;4BAC/G,4EAA4E,CAAC;qBACpF;yBAAM;wBACH,QAAQ,CAAC,iBAAiB,GAAG,oCAAoC;4BAC7D,mDAAmD,CAAC;qBAC3D;oBACL,sCAAsC;iBACrC;qBAAM,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,0BAAa,CAAC,kBAAkB,EAAE;oBACxE,QAAQ,CAAC,iBAAiB,GAAG,0CAA0C,CAAC;iBAC3E;aACJ;SACJ;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAzID,0CAyIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zowe/core-for-zowe-sdk",
3
- "version": "7.16.4",
3
+ "version": "7.17.0",
4
4
  "description": "Core libraries shared by Zowe SDK packages",
5
5
  "author": "Zowe",
6
6
  "license": "EPL-2.0",
@@ -49,8 +49,8 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/node": "^14.18.28",
52
- "@zowe/cli-test-utils": "7.16.4",
53
- "@zowe/imperative": "5.14.2",
52
+ "@zowe/cli-test-utils": "7.16.5",
53
+ "@zowe/imperative": "5.15.1",
54
54
  "chalk": "^4.1.0",
55
55
  "eslint": "^8.22.0",
56
56
  "madge": "^4.0.1",