@azure/core-client 1.6.2-alpha.20221129.2 → 1.7.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.
package/dist/index.js CHANGED
@@ -502,8 +502,9 @@ function serializeBasicTypes(typeName, objectName, value) {
502
502
  !(value instanceof ArrayBuffer) &&
503
503
  !ArrayBuffer.isView(value) &&
504
504
  // File objects count as a type of Blob, so we want to use instanceof explicitly
505
- !((typeof Blob === "function" || typeof Blob === "object") && value instanceof Blob)) {
506
- throw new Error(`${objectName} must be a string, Blob, ArrayBuffer, ArrayBufferView, or NodeJS.ReadableStream.`);
505
+ !((typeof Blob === "function" || typeof Blob === "object") && value instanceof Blob) &&
506
+ objectType !== "function") {
507
+ throw new Error(`${objectName} must be a string, Blob, ArrayBuffer, ArrayBufferView, NodeJS.ReadableStream, or () => NodeJS.ReadableStream.`);
507
508
  }
508
509
  }
509
510
  }
@@ -1147,7 +1148,14 @@ function getPropertyFromParameterPath(parent, parameterPath) {
1147
1148
  return result;
1148
1149
  }
1149
1150
  const operationRequestMap = new WeakMap();
1151
+ const originalRequestSymbol = Symbol.for("@azure/core-client original request");
1152
+ function hasOriginalRequest(request) {
1153
+ return originalRequestSymbol in request;
1154
+ }
1150
1155
  function getOperationRequestInfo(request) {
1156
+ if (hasOriginalRequest(request)) {
1157
+ return getOperationRequestInfo(request[originalRequestSymbol]);
1158
+ }
1151
1159
  let info = operationRequestMap.get(request);
1152
1160
  if (!info) {
1153
1161
  info = {};
@@ -1229,7 +1237,7 @@ async function deserializeResponseBody(jsonContentTypes, xmlContentTypes, respon
1229
1237
  return parsedResponse;
1230
1238
  }
1231
1239
  const responseSpec = getOperationResponseMap(parsedResponse);
1232
- const { error, shouldReturnResponse } = handleErrorResponse(parsedResponse, operationSpec, responseSpec);
1240
+ const { error, shouldReturnResponse } = handleErrorResponse(parsedResponse, operationSpec, responseSpec, options);
1233
1241
  if (error) {
1234
1242
  throw error;
1235
1243
  }
@@ -1248,7 +1256,7 @@ async function deserializeResponseBody(jsonContentTypes, xmlContentTypes, respon
1248
1256
  : [];
1249
1257
  }
1250
1258
  try {
1251
- parsedResponse.parsedBody = operationSpec.serializer.deserialize(responseSpec.bodyMapper, valueToDeserialize, "operationRes.parsedBody");
1259
+ parsedResponse.parsedBody = operationSpec.serializer.deserialize(responseSpec.bodyMapper, valueToDeserialize, "operationRes.parsedBody", options);
1252
1260
  }
1253
1261
  catch (deserializeError) {
1254
1262
  const restError = new coreRestPipeline.RestError(`Error ${deserializeError} occurred in deserializing the responseBody - ${parsedResponse.bodyAsText}`, {
@@ -1274,7 +1282,7 @@ function isOperationSpecEmpty(operationSpec) {
1274
1282
  return (expectedStatusCodes.length === 0 ||
1275
1283
  (expectedStatusCodes.length === 1 && expectedStatusCodes[0] === "default"));
1276
1284
  }
1277
- function handleErrorResponse(parsedResponse, operationSpec, responseSpec) {
1285
+ function handleErrorResponse(parsedResponse, operationSpec, responseSpec, options) {
1278
1286
  var _a;
1279
1287
  const isSuccessByStatus = 200 <= parsedResponse.status && parsedResponse.status < 300;
1280
1288
  const isExpectedStatusCode = isOperationSpecEmpty(operationSpec)
@@ -1321,7 +1329,7 @@ function handleErrorResponse(parsedResponse, operationSpec, responseSpec) {
1321
1329
  valueToDeserialize = parsedBody[elementName];
1322
1330
  }
1323
1331
  }
1324
- deserializedError = operationSpec.serializer.deserialize(defaultBodyMapper, valueToDeserialize, "error.response.parsedBody");
1332
+ deserializedError = operationSpec.serializer.deserialize(defaultBodyMapper, valueToDeserialize, "error.response.parsedBody", options);
1325
1333
  }
1326
1334
  const internalError = parsedBody.error || deserializedError || parsedBody;
1327
1335
  error.code = internalError.code;