@jerome-benoit/sap-ai-provider 4.6.4 → 4.6.5

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 (20) hide show
  1. package/dist/{chunk-GLGLTUZM.js → chunk-DVRCVX3D.js} +21 -18
  2. package/dist/{chunk-GLGLTUZM.js.map → chunk-DVRCVX3D.js.map} +1 -1
  3. package/dist/{chunk-UZU24CQH.js → chunk-IW3HT2O2.js} +3 -3
  4. package/dist/{chunk-ORUTDXQO.js → chunk-MUVZG52Z.js} +2 -2
  5. package/dist/{chunk-VVJCWWDC.js → chunk-RIDFTJHB.js} +3 -3
  6. package/dist/{foundation-models-embedding-model-strategy-JTZUKIYM.js → foundation-models-embedding-model-strategy-LVCLPX77.js} +4 -4
  7. package/dist/{foundation-models-language-model-strategy-NT5HVEM5.js → foundation-models-language-model-strategy-PZMQYE3T.js} +4 -4
  8. package/dist/index.cjs +20 -17
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.js +5 -5
  11. package/dist/{orchestration-embedding-model-strategy-BBCIC45Q.js → orchestration-embedding-model-strategy-SJ6AR4CA.js} +4 -4
  12. package/dist/{orchestration-language-model-strategy-YPDJAXBL.js → orchestration-language-model-strategy-B36B6QYQ.js} +4 -4
  13. package/package.json +1 -1
  14. /package/dist/{chunk-UZU24CQH.js.map → chunk-IW3HT2O2.js.map} +0 -0
  15. /package/dist/{chunk-ORUTDXQO.js.map → chunk-MUVZG52Z.js.map} +0 -0
  16. /package/dist/{chunk-VVJCWWDC.js.map → chunk-RIDFTJHB.js.map} +0 -0
  17. /package/dist/{foundation-models-embedding-model-strategy-JTZUKIYM.js.map → foundation-models-embedding-model-strategy-LVCLPX77.js.map} +0 -0
  18. /package/dist/{foundation-models-language-model-strategy-NT5HVEM5.js.map → foundation-models-language-model-strategy-PZMQYE3T.js.map} +0 -0
  19. /package/dist/{orchestration-embedding-model-strategy-BBCIC45Q.js.map → orchestration-embedding-model-strategy-SJ6AR4CA.js.map} +0 -0
  20. /package/dist/{orchestration-language-model-strategy-YPDJAXBL.js.map → orchestration-language-model-strategy-B36B6QYQ.js.map} +0 -0
@@ -30051,7 +30051,7 @@ var UnsupportedFeatureError = class extends Error {
30051
30051
  };
30052
30052
  function convertSAPErrorToAPICallError(errorResponse, context) {
30053
30053
  const { code, location, message, requestId } = extractErrorFields(errorResponse);
30054
- const statusCode = getStatusCodeFromSAPError(code);
30054
+ const statusCode = getStatusCodeFromSAPError(code, context?.httpStatusCode);
30055
30055
  const responseBody = JSON.stringify({
30056
30056
  error: {
30057
30057
  code,
@@ -30112,10 +30112,11 @@ function convertToAISDKError(error, context) {
30112
30112
  return error;
30113
30113
  }
30114
30114
  const rootError = getRootError(error);
30115
- const errorResponse = findOrchestrationErrorResponse(error);
30115
+ const errorResponse = findStructuredErrorResponse(error);
30116
30116
  if (errorResponse) {
30117
30117
  return convertSAPErrorToAPICallError(errorResponse, {
30118
30118
  ...context,
30119
+ httpStatusCode: getAxiosError(error)?.response?.status,
30119
30120
  responseHeaders: context?.responseHeaders ?? getAxiosResponseHeaders(error)
30120
30121
  });
30121
30122
  }
@@ -30276,7 +30277,7 @@ function extractModelIdentifier(message, location) {
30276
30277
  return void 0;
30277
30278
  }
30278
30279
  function extractSAPErrorMessage(error) {
30279
- const errorResponse = findOrchestrationErrorResponse(error);
30280
+ const errorResponse = findStructuredErrorResponse(error);
30280
30281
  if (errorResponse) {
30281
30282
  return extractErrorFields(errorResponse).message;
30282
30283
  }
@@ -30286,18 +30287,18 @@ function extractSAPErrorMessage(error) {
30286
30287
  }
30287
30288
  return typeof rootError === "string" ? rootError : void 0;
30288
30289
  }
30289
- function findOrchestrationErrorResponse(error) {
30290
+ function findStructuredErrorResponse(error) {
30290
30291
  const rootError = getRootError(error);
30291
- if (isOrchestrationErrorResponse(rootError)) {
30292
+ if (isStructuredErrorResponse(rootError)) {
30292
30293
  return rootError;
30293
30294
  }
30294
30295
  const axiosData = getAxiosError(error)?.response?.data;
30295
- if (axiosData && isOrchestrationErrorResponse(axiosData)) {
30296
+ if (axiosData && isStructuredErrorResponse(axiosData)) {
30296
30297
  return axiosData;
30297
30298
  }
30298
30299
  if (rootError instanceof Error) {
30299
30300
  const parsed = tryExtractSAPErrorFromMessage(rootError.message);
30300
- if (parsed && isOrchestrationErrorResponse(parsed)) {
30301
+ if (parsed && isStructuredErrorResponse(parsed)) {
30301
30302
  return parsed;
30302
30303
  }
30303
30304
  }
@@ -30324,11 +30325,13 @@ function getAxiosResponseHeaders(error) {
30324
30325
  function getRootError(error) {
30325
30326
  return error instanceof Error && (0, import_util.isErrorWithCause)(error) ? error.rootCause : error;
30326
30327
  }
30327
- function getStatusCodeFromSAPError(code) {
30328
- if (!code) return HTTP_STATUS.INTERNAL_ERROR;
30329
- if (code >= 100 && code < 600) {
30328
+ function getStatusCodeFromSAPError(code, httpStatusCode) {
30329
+ if (code && code >= 100 && code < 600) {
30330
30330
  return code;
30331
30331
  }
30332
+ if (httpStatusCode && httpStatusCode >= 100 && httpStatusCode < 600) {
30333
+ return httpStatusCode;
30334
+ }
30332
30335
  return HTTP_STATUS.INTERNAL_ERROR;
30333
30336
  }
30334
30337
  function isAbortError(error) {
@@ -30340,7 +30343,10 @@ function isAbortError(error) {
30340
30343
  }
30341
30344
  return false;
30342
30345
  }
30343
- function isOrchestrationErrorResponse(error) {
30346
+ function isRetryable(statusCode) {
30347
+ return statusCode === HTTP_STATUS.REQUEST_TIMEOUT || statusCode === HTTP_STATUS.CONFLICT || statusCode === HTTP_STATUS.RATE_LIMIT || statusCode >= HTTP_STATUS.INTERNAL_ERROR && statusCode < 600;
30348
+ }
30349
+ function isStructuredErrorResponse(error) {
30344
30350
  if (error === null || typeof error !== "object" || !("error" in error)) {
30345
30351
  return false;
30346
30352
  }
@@ -30356,7 +30362,7 @@ function isOrchestrationErrorResponse(error) {
30356
30362
  if (typeof errorEntry.message !== "string") {
30357
30363
  return false;
30358
30364
  }
30359
- if ("code" in entry && typeof errorEntry.code !== "number") {
30365
+ if ("code" in entry && errorEntry.code != null && typeof errorEntry.code !== "number") {
30360
30366
  return false;
30361
30367
  }
30362
30368
  return true;
@@ -30369,14 +30375,11 @@ function isOrchestrationErrorResponse(error) {
30369
30375
  if (typeof errorObj.message !== "string") {
30370
30376
  return false;
30371
30377
  }
30372
- if ("code" in innerError && typeof errorObj.code !== "number") {
30378
+ if ("code" in innerError && errorObj.code != null && typeof errorObj.code !== "number") {
30373
30379
  return false;
30374
30380
  }
30375
30381
  return true;
30376
30382
  }
30377
- function isRetryable(statusCode) {
30378
- return statusCode === HTTP_STATUS.REQUEST_TIMEOUT || statusCode === HTTP_STATUS.CONFLICT || statusCode === HTTP_STATUS.RATE_LIMIT || statusCode >= HTTP_STATUS.INTERNAL_ERROR && statusCode < 600;
30379
- }
30380
30383
  function serializeAxiosResponseData(data, maxLength = 2e3) {
30381
30384
  if (data === void 0) return void 0;
30382
30385
  let serialized;
@@ -30412,7 +30415,7 @@ function tryExtractSAPErrorFromMessage(message) {
30412
30415
  }
30413
30416
 
30414
30417
  // src/version.ts
30415
- var VERSION = true ? "4.6.4" : "0.0.0-test";
30418
+ var VERSION = true ? "4.6.5" : "0.0.0-test";
30416
30419
 
30417
30420
  export {
30418
30421
  __toESM,
@@ -30466,4 +30469,4 @@ mime-types/index.js:
30466
30469
  axios/dist/node/axios.cjs:
30467
30470
  (*! Axios v1.14.0 Copyright (c) 2026 Matt Zabriskie and contributors *)
30468
30471
  */
30469
- //# sourceMappingURL=chunk-GLGLTUZM.js.map
30472
+ //# sourceMappingURL=chunk-DVRCVX3D.js.map