@goplus123/core-api 1.1.7 → 1.1.8

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/dist/index.js CHANGED
@@ -2182,7 +2182,26 @@ var UnifiedApiClient = class {
2182
2182
  serviceTypeName: service.typeName,
2183
2183
  methodName
2184
2184
  });
2185
- if (!adapter) return res;
2185
+ if (!adapter) {
2186
+ if (this.isGrpcBaseResponse(res) && !this.isGrpcOk(res)) {
2187
+ throw new GrpcBizError({
2188
+ endpointId: endpoint.id,
2189
+ serviceTypeName: service.typeName,
2190
+ methodName,
2191
+ code: this.normalizeNumber(
2192
+ this.pickField(res, ["code", "errCode", "errorCode", "resultCode"])
2193
+ ),
2194
+ status: this.normalizeNumber(
2195
+ this.pickField(res, ["status", "statusCode", "httpStatus", "http_code"])
2196
+ ),
2197
+ message: this.normalizeString(
2198
+ this.pickField(res, ["message", "msg", "error", "errMsg", "errmsg", "errorMessage"])
2199
+ ) ?? "Request failed",
2200
+ raw: res
2201
+ });
2202
+ }
2203
+ return res;
2204
+ }
2186
2205
  if (!this.isGrpcOkWithAdapter(res, adapter)) {
2187
2206
  throw new GrpcBizError({
2188
2207
  endpointId: endpoint.id,
@@ -2231,6 +2250,12 @@ var UnifiedApiClient = class {
2231
2250
  }
2232
2251
  return void 0;
2233
2252
  }
2253
+ isGrpcBaseResponse(value) {
2254
+ if (!value || typeof value !== "object") return false;
2255
+ const typeName = value.$typeName;
2256
+ if (typeof typeName !== "string" || typeName.length === 0) return false;
2257
+ return /(^|\.)BaseResponse$/.test(typeName);
2258
+ }
2234
2259
  normalizeNumber(value) {
2235
2260
  if (typeof value === "number" && Number.isFinite(value)) return value;
2236
2261
  if (typeof value === "string") {