@aws-sdk/client-bedrock-runtime
Advanced tools
Comparing version
@@ -452,2 +452,3 @@ "use strict"; | ||
// src/protocols/Aws_restJson1.ts | ||
var import_core2 = require("@aws-sdk/core"); | ||
@@ -512,5 +513,5 @@ | ||
...output, | ||
body: await parseErrorBody(output.body, context) | ||
body: await (0, import_core2.parseJsonErrorBody)(output.body, context) | ||
}; | ||
const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); | ||
const errorCode = (0, import_core2.loadRestJsonErrorCode)(output, parsedOutput.body); | ||
switch (errorCode) { | ||
@@ -732,3 +733,3 @@ case "AccessDeniedException": | ||
...output, | ||
body: await parseBody(output.body, context) | ||
body: await (0, import_core2.parseJsonBody)(output.body, context) | ||
}; | ||
@@ -740,3 +741,3 @@ return de_InternalServerExceptionRes(parsedOutput, context); | ||
...output, | ||
body: await parseBody(output.body, context) | ||
body: await (0, import_core2.parseJsonBody)(output.body, context) | ||
}; | ||
@@ -748,3 +749,3 @@ return de_ModelStreamErrorExceptionRes(parsedOutput, context); | ||
...output, | ||
body: await parseBody(output.body, context) | ||
body: await (0, import_core2.parseJsonBody)(output.body, context) | ||
}; | ||
@@ -755,3 +756,3 @@ return de_ModelTimeoutExceptionRes(parsedOutput, context); | ||
const contents = {}; | ||
const data = await parseBody(output.body, context); | ||
const data = await (0, import_core2.parseJsonBody)(output.body, context); | ||
Object.assign(contents, de_PayloadPart(data, context)); | ||
@@ -763,3 +764,3 @@ return contents; | ||
...output, | ||
body: await parseBody(output.body, context) | ||
body: await (0, import_core2.parseJsonBody)(output.body, context) | ||
}; | ||
@@ -771,3 +772,3 @@ return de_ThrottlingExceptionRes(parsedOutput, context); | ||
...output, | ||
body: await parseBody(output.body, context) | ||
body: await (0, import_core2.parseJsonBody)(output.body, context) | ||
}; | ||
@@ -787,3 +788,2 @@ return de_ValidationExceptionRes(parsedOutput, context); | ||
}), "deserializeMetadata"); | ||
var collectBodyString = /* @__PURE__ */ __name((streamBody, context) => (0, import_smithy_client.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body)), "collectBodyString"); | ||
var isSerializableHeaderValue = /* @__PURE__ */ __name((value) => value !== void 0 && value !== null && value !== "" && (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) && (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0), "isSerializableHeaderValue"); | ||
@@ -795,42 +795,2 @@ var _a = "accept"; | ||
var _xabct = "x-amzn-bedrock-content-type"; | ||
var parseBody = /* @__PURE__ */ __name((streamBody, context) => collectBodyString(streamBody, context).then((encoded) => { | ||
if (encoded.length) { | ||
return JSON.parse(encoded); | ||
} | ||
return {}; | ||
}), "parseBody"); | ||
var parseErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => { | ||
const value = await parseBody(errorBody, context); | ||
value.message = value.message ?? value.Message; | ||
return value; | ||
}, "parseErrorBody"); | ||
var loadRestJsonErrorCode = /* @__PURE__ */ __name((output, data) => { | ||
const findKey = /* @__PURE__ */ __name((object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()), "findKey"); | ||
const sanitizeErrorCode = /* @__PURE__ */ __name((rawValue) => { | ||
let cleanValue = rawValue; | ||
if (typeof cleanValue === "number") { | ||
cleanValue = cleanValue.toString(); | ||
} | ||
if (cleanValue.indexOf(",") >= 0) { | ||
cleanValue = cleanValue.split(",")[0]; | ||
} | ||
if (cleanValue.indexOf(":") >= 0) { | ||
cleanValue = cleanValue.split(":")[0]; | ||
} | ||
if (cleanValue.indexOf("#") >= 0) { | ||
cleanValue = cleanValue.split("#")[1]; | ||
} | ||
return cleanValue; | ||
}, "sanitizeErrorCode"); | ||
const headerKey = findKey(output.headers, "x-amzn-errortype"); | ||
if (headerKey !== void 0) { | ||
return sanitizeErrorCode(output.headers[headerKey]); | ||
} | ||
if (data.code !== void 0) { | ||
return sanitizeErrorCode(data.code); | ||
} | ||
if (data["__type"] !== void 0) { | ||
return sanitizeErrorCode(data["__type"]); | ||
} | ||
}, "loadRestJsonErrorCode"); | ||
@@ -837,0 +797,0 @@ // src/commands/InvokeModelCommand.ts |
@@ -0,1 +1,2 @@ | ||
import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core"; | ||
import { requestBuilder as rb } from "@smithy/core"; | ||
@@ -338,41 +339,1 @@ import { collectBody, decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectString as __expectString, map, take, withBaseException, } from "@smithy/smithy-client"; | ||
const _xabct = "x-amzn-bedrock-content-type"; | ||
const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => { | ||
if (encoded.length) { | ||
return JSON.parse(encoded); | ||
} | ||
return {}; | ||
}); | ||
const parseErrorBody = async (errorBody, context) => { | ||
const value = await parseBody(errorBody, context); | ||
value.message = value.message ?? value.Message; | ||
return value; | ||
}; | ||
const loadRestJsonErrorCode = (output, data) => { | ||
const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); | ||
const sanitizeErrorCode = (rawValue) => { | ||
let cleanValue = rawValue; | ||
if (typeof cleanValue === "number") { | ||
cleanValue = cleanValue.toString(); | ||
} | ||
if (cleanValue.indexOf(",") >= 0) { | ||
cleanValue = cleanValue.split(",")[0]; | ||
} | ||
if (cleanValue.indexOf(":") >= 0) { | ||
cleanValue = cleanValue.split(":")[0]; | ||
} | ||
if (cleanValue.indexOf("#") >= 0) { | ||
cleanValue = cleanValue.split("#")[1]; | ||
} | ||
return cleanValue; | ||
}; | ||
const headerKey = findKey(output.headers, "x-amzn-errortype"); | ||
if (headerKey !== undefined) { | ||
return sanitizeErrorCode(output.headers[headerKey]); | ||
} | ||
if (data.code !== undefined) { | ||
return sanitizeErrorCode(data.code); | ||
} | ||
if (data["__type"] !== undefined) { | ||
return sanitizeErrorCode(data["__type"]); | ||
} | ||
}; |
{ | ||
"name": "@aws-sdk/client-bedrock-runtime", | ||
"description": "AWS SDK for JavaScript Bedrock Runtime Client for Node.js, Browser and React Native", | ||
"version": "3.525.0", | ||
"version": "3.529.0", | ||
"scripts": { | ||
@@ -23,5 +23,5 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'", | ||
"@aws-crypto/sha256-js": "3.0.0", | ||
"@aws-sdk/client-sts": "3.525.0", | ||
"@aws-sdk/core": "3.525.0", | ||
"@aws-sdk/credential-provider-node": "3.525.0", | ||
"@aws-sdk/client-sts": "3.529.0", | ||
"@aws-sdk/core": "3.529.0", | ||
"@aws-sdk/credential-provider-node": "3.529.0", | ||
"@aws-sdk/middleware-host-header": "3.523.0", | ||
@@ -28,0 +28,0 @@ "@aws-sdk/middleware-logger": "3.523.0", |
201148
-1.36%4086
-1.9%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated