@xylex-group/athena 2.10.0 → 2.12.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/README.md +112 -28
- package/dist/browser.cjs +333 -240
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +9 -8
- package/dist/browser.d.ts +9 -8
- package/dist/browser.js +333 -240
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +306 -240
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -3
- package/dist/cli/index.d.ts +4 -3
- package/dist/cli/index.js +306 -240
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-BYii6dU9.d.ts → client-C3x75Zgn.d.cts} +22 -9
- package/dist/{client-B7EQ_hPV.d.cts → client-QUbAs7E8.d.ts} +22 -9
- package/dist/index.cjs +333 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +333 -240
- package/dist/index.js.map +1 -1
- package/dist/{model-form-DACdBLYG.d.cts → model-form-CD1uhWSh.d.cts} +2 -1
- package/dist/{model-form-ByvyyvxB.d.ts → model-form-Dm69I-oO.d.ts} +2 -1
- package/dist/{module-DbHlxpeR.d.ts → module-CW3tWJ10.d.ts} +5 -4
- package/dist/{module-DC96HJa3.d.cts → module-Cxcurfes.d.cts} +5 -4
- package/dist/next/client.cjs +333 -240
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +4 -3
- package/dist/next/client.d.ts +4 -3
- package/dist/next/client.js +333 -240
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +333 -240
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +4 -3
- package/dist/next/server.d.ts +4 -3
- package/dist/next/server.js +333 -240
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-CmUZsXsi.d.cts → pipeline-B14jVK7J.d.cts} +1 -1
- package/dist/{pipeline-DZMsPxUg.d.ts → pipeline-BAwb6Vzm.d.ts} +1 -1
- package/dist/react.cjs +234 -98
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -4
- package/dist/react.d.ts +5 -4
- package/dist/react.js +234 -98
- package/dist/react.js.map +1 -1
- package/dist/{shared-DRptGBWP.d.ts → shared-0Kdc74lu.d.ts} +2 -2
- package/dist/{shared-BMVGMnti.d.cts → shared-C0wVICRv.d.cts} +2 -2
- package/dist/{types-C-YvfgYh.d.cts → types-BcVmPBP-.d.ts} +2 -1
- package/dist/types-Cq4-NoB4.d.ts +204 -0
- package/dist/types-CwJCPpLD.d.cts +236 -0
- package/dist/types-CwJCPpLD.d.ts +236 -0
- package/dist/{types-CRjDwmtJ.d.ts → types-DMOoYnPS.d.cts} +2 -1
- package/dist/types-Dr849HD6.d.cts +204 -0
- package/dist/utils.cjs +276 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +58 -1
- package/dist/utils.d.ts +58 -1
- package/dist/utils.js +269 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/types-BeZIHduP.d.cts +0 -428
- package/dist/types-BeZIHduP.d.ts +0 -428
package/dist/index.js
CHANGED
|
@@ -802,42 +802,31 @@ var getCookieCache = async (request2, config) => {
|
|
|
802
802
|
};
|
|
803
803
|
};
|
|
804
804
|
|
|
805
|
-
//
|
|
806
|
-
var package_default = {
|
|
807
|
-
version: "2.10.0"
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
// src/sdk-version.ts
|
|
811
|
-
var PACKAGE_VERSION = package_default.version;
|
|
812
|
-
function buildSdkHeaderValue(sdkName) {
|
|
813
|
-
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
// src/gateway/client.ts
|
|
817
|
-
var DEFAULT_CLIENT = "railway_direct";
|
|
818
|
-
var SDK_NAME = "xylex-group/athena";
|
|
819
|
-
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
805
|
+
// src/utils/athena-request-headers.ts
|
|
820
806
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
807
|
+
var API_KEY_HEADER_CANDIDATES = ["x-api-key", "apikey"];
|
|
808
|
+
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
809
|
+
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
810
|
+
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
811
|
+
var CLIENT_HEADER_CANDIDATES = ["X-Athena-Client", "x-athena-client"];
|
|
812
|
+
var PG_URI_HEADER_CANDIDATES = ["x-pg-uri"];
|
|
813
|
+
var JDBC_URI_HEADER_CANDIDATES = ["x-athena-jdbc-url", "x-jdbc-url"];
|
|
814
|
+
var PROFILE_RULES = {
|
|
815
|
+
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
816
|
+
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
817
|
+
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
818
|
+
auth: { apiKeys: true, routing: false, authMirror: false, authBearer: true, contentType: true },
|
|
819
|
+
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
820
|
+
};
|
|
836
821
|
function normalizeHeaderValue(value) {
|
|
837
822
|
return value ? value : void 0;
|
|
838
823
|
}
|
|
839
|
-
function
|
|
840
|
-
return
|
|
824
|
+
function mergeExtraHeaders(configHeaders, callHeaders) {
|
|
825
|
+
return { ...configHeaders ?? {}, ...callHeaders ?? {} };
|
|
826
|
+
}
|
|
827
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
828
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
829
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
841
830
|
}
|
|
842
831
|
function resolveHeaderValue(headers, candidates) {
|
|
843
832
|
for (const candidate of candidates) {
|
|
@@ -854,13 +843,20 @@ function resolveHeaderValue(headers, candidates) {
|
|
|
854
843
|
}
|
|
855
844
|
return void 0;
|
|
856
845
|
}
|
|
846
|
+
function isCacheControlHeaderName(name) {
|
|
847
|
+
return name.toLowerCase() === "cache-control";
|
|
848
|
+
}
|
|
849
|
+
function normalizeBearerToken(value) {
|
|
850
|
+
const trimmed = value.trim();
|
|
851
|
+
const match = trimmed.match(/^Bearer\s+(.+)$/i);
|
|
852
|
+
return match?.[1]?.trim() ?? trimmed;
|
|
853
|
+
}
|
|
857
854
|
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
858
855
|
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
859
856
|
if (!authorization) {
|
|
860
857
|
return void 0;
|
|
861
858
|
}
|
|
862
|
-
const
|
|
863
|
-
const token = match?.[1]?.trim();
|
|
859
|
+
const token = normalizeBearerToken(authorization);
|
|
864
860
|
return token ? token : void 0;
|
|
865
861
|
}
|
|
866
862
|
function resolveSessionTokenFromCookieHeader(headers) {
|
|
@@ -870,6 +866,207 @@ function resolveSessionTokenFromCookieHeader(headers) {
|
|
|
870
866
|
}
|
|
871
867
|
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
872
868
|
}
|
|
869
|
+
function resolveBackendType(backend) {
|
|
870
|
+
if (!backend) {
|
|
871
|
+
return void 0;
|
|
872
|
+
}
|
|
873
|
+
return typeof backend === "string" ? backend : backend.type;
|
|
874
|
+
}
|
|
875
|
+
function resolveRequestHeaderOverrides(config, options, defaults) {
|
|
876
|
+
return {
|
|
877
|
+
apiKey: options?.apiKey ?? config.apiKey,
|
|
878
|
+
athenaKey: options?.athenaKey ?? config.athenaKey,
|
|
879
|
+
client: options?.client ?? config.client ?? defaults?.client,
|
|
880
|
+
userId: options?.userId ?? config.userId,
|
|
881
|
+
organizationId: options?.organizationId ?? config.organizationId,
|
|
882
|
+
backend: options?.backend ?? config.backend,
|
|
883
|
+
publishEvent: options?.publishEvent ?? config.publishEvent,
|
|
884
|
+
stripNulls: options?.stripNulls ?? config.stripNulls ?? defaults?.stripNulls,
|
|
885
|
+
bearerToken: options?.bearerToken ?? config.bearerToken,
|
|
886
|
+
cookie: options?.cookie ?? config.cookie,
|
|
887
|
+
sessionToken: options?.sessionToken ?? config.sessionToken,
|
|
888
|
+
pgUri: options?.pgUri ?? config.pgUri,
|
|
889
|
+
jdbcUrl: options?.jdbcUrl ?? config.jdbcUrl,
|
|
890
|
+
forceNoCache: Boolean(config.forceNoCache || options?.forceNoCache),
|
|
891
|
+
configHeaders: config.headers,
|
|
892
|
+
callHeaders: options?.headers
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, extras) {
|
|
896
|
+
const rules = PROFILE_RULES[profile];
|
|
897
|
+
return buildAthenaRequestHeaders({
|
|
898
|
+
profile,
|
|
899
|
+
sdkHeaderValue,
|
|
900
|
+
...resolveRequestHeaderOverrides(config, options, {
|
|
901
|
+
client: extras?.client ?? void 0,
|
|
902
|
+
stripNulls: extras?.stripNulls ?? (rules.stripNullsDefault ? true : void 0)
|
|
903
|
+
}),
|
|
904
|
+
contentType: extras?.contentType ?? (rules.contentType ? "application/json" : void 0),
|
|
905
|
+
accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
909
|
+
if (apiKey) {
|
|
910
|
+
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
911
|
+
headers.apikey = apiKey;
|
|
912
|
+
}
|
|
913
|
+
if (!hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
914
|
+
headers["x-api-key"] = apiKey;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
918
|
+
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
919
|
+
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
923
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
924
|
+
const rules = PROFILE_RULES[input.profile];
|
|
925
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
926
|
+
if (explicitCookie) {
|
|
927
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
928
|
+
}
|
|
929
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
930
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
931
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
932
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
933
|
+
headers.Cookie = explicitCookie;
|
|
934
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
935
|
+
headers.Cookie = cookieFromHeaders;
|
|
936
|
+
}
|
|
937
|
+
const explicitBearerToken = (() => {
|
|
938
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
939
|
+
if (configured) {
|
|
940
|
+
return normalizeBearerToken(configured);
|
|
941
|
+
}
|
|
942
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
943
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
944
|
+
})();
|
|
945
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
946
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
947
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
948
|
+
}
|
|
949
|
+
if (rules.authMirror) {
|
|
950
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
951
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
952
|
+
}
|
|
953
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
954
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
955
|
+
}
|
|
956
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
957
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
961
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
962
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
963
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
964
|
+
headers["x-pg-uri"] = pgUri;
|
|
965
|
+
}
|
|
966
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
967
|
+
if (jdbcUrl) {
|
|
968
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
969
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
970
|
+
}
|
|
971
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
972
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function buildAthenaRequestHeaders(input) {
|
|
977
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
978
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
979
|
+
const rules = PROFILE_RULES[input.profile];
|
|
980
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
981
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
982
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
983
|
+
const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
984
|
+
const headers = {
|
|
985
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
986
|
+
};
|
|
987
|
+
if (rules.contentType) {
|
|
988
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
989
|
+
}
|
|
990
|
+
if (input.accept ?? rules.accept) {
|
|
991
|
+
headers.Accept = input.accept ?? "application/json";
|
|
992
|
+
}
|
|
993
|
+
if (rules.routing) {
|
|
994
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
995
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
996
|
+
}
|
|
997
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
998
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
999
|
+
}
|
|
1000
|
+
if (finalClient) {
|
|
1001
|
+
headers["X-Athena-Client"] = finalClient;
|
|
1002
|
+
}
|
|
1003
|
+
const backendType = resolveBackendType(input.backend);
|
|
1004
|
+
if (backendType) {
|
|
1005
|
+
headers["X-Backend-Type"] = backendType;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof input.stripNulls === "boolean") {
|
|
1008
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
1009
|
+
} else if (rules.stripNullsDefault) {
|
|
1010
|
+
headers["X-Strip-Nulls"] = "true";
|
|
1011
|
+
}
|
|
1012
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
1013
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
1017
|
+
applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
|
|
1018
|
+
}
|
|
1019
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
1020
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
1021
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
1022
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
1023
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
const normalized = normalizeHeaderValue(value);
|
|
1030
|
+
if (normalized) {
|
|
1031
|
+
headers[key] = normalized;
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
if (forceNoCache) {
|
|
1035
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
1036
|
+
}
|
|
1037
|
+
return headers;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// package.json
|
|
1041
|
+
var package_default = {
|
|
1042
|
+
version: "2.12.0"
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
// src/sdk-version.ts
|
|
1046
|
+
var PACKAGE_VERSION = package_default.version;
|
|
1047
|
+
function buildSdkHeaderValue(sdkName) {
|
|
1048
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/gateway/client.ts
|
|
1052
|
+
var DEFAULT_CLIENT = "railway_direct";
|
|
1053
|
+
var SDK_NAME = "xylex-group/athena";
|
|
1054
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
1055
|
+
function parseResponseBody(rawText, contentType) {
|
|
1056
|
+
if (!rawText) {
|
|
1057
|
+
return { parsed: null, parseFailed: false };
|
|
1058
|
+
}
|
|
1059
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
1060
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
1061
|
+
if (!looksJson) {
|
|
1062
|
+
return { parsed: rawText, parseFailed: false };
|
|
1063
|
+
}
|
|
1064
|
+
try {
|
|
1065
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
1066
|
+
} catch {
|
|
1067
|
+
return { parsed: rawText, parseFailed: true };
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
873
1070
|
function isRecord(value) {
|
|
874
1071
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
875
1072
|
}
|
|
@@ -996,71 +1193,10 @@ function buildRpcGetEndpoint(payload) {
|
|
|
996
1193
|
return withQuery;
|
|
997
1194
|
}
|
|
998
1195
|
function buildHeaders(config, options) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
...config.headers ?? {},
|
|
1003
|
-
...options?.headers ?? {}
|
|
1004
|
-
};
|
|
1005
|
-
const headerClient = extraHeaders["x-athena-client"] ?? extraHeaders["X-Athena-Client"];
|
|
1006
|
-
const finalClient = options?.client ?? config.client ?? (typeof headerClient === "string" ? headerClient : void 0) ?? DEFAULT_CLIENT;
|
|
1007
|
-
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
1008
|
-
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
1009
|
-
const headers = {
|
|
1010
|
-
"Content-Type": "application/json",
|
|
1011
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE
|
|
1012
|
-
};
|
|
1013
|
-
if (options?.userId ?? config.userId) {
|
|
1014
|
-
headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
|
|
1015
|
-
}
|
|
1016
|
-
if (options?.organizationId ?? config.organizationId) {
|
|
1017
|
-
headers["X-Organization-Id"] = options?.organizationId ?? config.organizationId ?? "";
|
|
1018
|
-
}
|
|
1019
|
-
if (finalClient) {
|
|
1020
|
-
headers["X-Athena-Client"] = finalClient;
|
|
1021
|
-
}
|
|
1022
|
-
const finalBackend = options?.backend ?? config.backend;
|
|
1023
|
-
if (finalBackend) {
|
|
1024
|
-
const type = typeof finalBackend === "string" ? finalBackend : finalBackend.type;
|
|
1025
|
-
if (type) headers["X-Backend-Type"] = type;
|
|
1026
|
-
}
|
|
1027
|
-
if (typeof mergedStripNulls === "boolean") {
|
|
1028
|
-
headers["X-Strip-Nulls"] = mergedStripNulls ? "true" : "false";
|
|
1029
|
-
}
|
|
1030
|
-
if (finalPublishEvent) {
|
|
1031
|
-
headers["X-Publish-Event"] = finalPublishEvent;
|
|
1032
|
-
}
|
|
1033
|
-
if (finalApiKey) {
|
|
1034
|
-
headers["apikey"] = finalApiKey;
|
|
1035
|
-
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
1036
|
-
}
|
|
1037
|
-
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
1038
|
-
"X-Athena-Auth-Session-Token"
|
|
1039
|
-
]);
|
|
1040
|
-
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
1041
|
-
if (derivedSessionToken) {
|
|
1042
|
-
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
1043
|
-
}
|
|
1044
|
-
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
1045
|
-
"X-Athena-Auth-Bearer-Token"
|
|
1046
|
-
]);
|
|
1047
|
-
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
1048
|
-
if (derivedBearerToken) {
|
|
1049
|
-
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
1050
|
-
}
|
|
1051
|
-
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
1052
|
-
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
1053
|
-
if (athenaClientKeys.includes(key)) return;
|
|
1054
|
-
if (forceNoCache && isCacheControlHeaderName(key)) return;
|
|
1055
|
-
const normalized = normalizeHeaderValue(value);
|
|
1056
|
-
if (normalized) {
|
|
1057
|
-
headers[key] = normalized;
|
|
1058
|
-
}
|
|
1196
|
+
return buildServiceRequestHeaders("gateway", SDK_HEADER_VALUE, config, options, {
|
|
1197
|
+
client: options?.client ?? config.client ?? DEFAULT_CLIENT,
|
|
1198
|
+
stripNulls: options?.stripNulls ?? true
|
|
1059
1199
|
});
|
|
1060
|
-
if (forceNoCache) {
|
|
1061
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
1062
|
-
}
|
|
1063
|
-
return headers;
|
|
1064
1200
|
}
|
|
1065
1201
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
1066
1202
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1788,19 +1924,12 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
|
|
|
1788
1924
|
var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
|
|
1789
1925
|
var SDK_NAME2 = "xylex-group/athena-auth";
|
|
1790
1926
|
var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
|
|
1791
|
-
var NO_CACHE_HEADER_VALUE2 = "no-cache";
|
|
1792
1927
|
function normalizeBaseUrl(baseUrl) {
|
|
1793
1928
|
return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
|
|
1794
1929
|
}
|
|
1795
1930
|
function isRecord3(value) {
|
|
1796
1931
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1797
1932
|
}
|
|
1798
|
-
function normalizeHeaderValue2(value) {
|
|
1799
|
-
return value ? value : void 0;
|
|
1800
|
-
}
|
|
1801
|
-
function isCacheControlHeaderName2(name) {
|
|
1802
|
-
return name.toLowerCase() === "cache-control";
|
|
1803
|
-
}
|
|
1804
1933
|
function parseResponseBody2(rawText, contentType) {
|
|
1805
1934
|
if (!rawText) {
|
|
1806
1935
|
return { parsed: null, parseFailed: false };
|
|
@@ -1865,6 +1994,21 @@ function copyDefinedField(target, source, targetKey, sourceKey) {
|
|
|
1865
1994
|
target[targetKey] = value;
|
|
1866
1995
|
}
|
|
1867
1996
|
}
|
|
1997
|
+
function normalizeEmailTemplateAttachmentsValue(value) {
|
|
1998
|
+
if (typeof value === "string" || value == null) {
|
|
1999
|
+
return value;
|
|
2000
|
+
}
|
|
2001
|
+
if (Array.isArray(value)) {
|
|
2002
|
+
return value.map((item) => normalizeEmailTemplateAttachmentsValue(item));
|
|
2003
|
+
}
|
|
2004
|
+
if (typeof value !== "object") {
|
|
2005
|
+
return value;
|
|
2006
|
+
}
|
|
2007
|
+
const attachment = { ...value };
|
|
2008
|
+
copyDefinedField(attachment, attachment, "file_url", "fileUrl");
|
|
2009
|
+
delete attachment.fileUrl;
|
|
2010
|
+
return attachment;
|
|
2011
|
+
}
|
|
1868
2012
|
function normalizeAdminEmailTemplatePayload(payload) {
|
|
1869
2013
|
const normalized = { ...payload };
|
|
1870
2014
|
copyDefinedField(normalized, payload, "template_key", "templateKey");
|
|
@@ -1875,6 +2019,17 @@ function normalizeAdminEmailTemplatePayload(payload) {
|
|
|
1875
2019
|
copyDefinedField(normalized, payload, "variable_bindings", "variableBindings");
|
|
1876
2020
|
copyDefinedField(normalized, payload, "attachment_failure_mode", "attachmentFailureMode");
|
|
1877
2021
|
copyDefinedField(normalized, payload, "is_active", "isActive");
|
|
2022
|
+
if (Object.hasOwn(payload, "attachments")) {
|
|
2023
|
+
normalized.attachments = normalizeEmailTemplateAttachmentsValue(payload.attachments);
|
|
2024
|
+
}
|
|
2025
|
+
delete normalized.templateKey;
|
|
2026
|
+
delete normalized.eventType;
|
|
2027
|
+
delete normalized.subjectTemplate;
|
|
2028
|
+
delete normalized.textTemplate;
|
|
2029
|
+
delete normalized.htmlTemplate;
|
|
2030
|
+
delete normalized.variableBindings;
|
|
2031
|
+
delete normalized.attachmentFailureMode;
|
|
2032
|
+
delete normalized.isActive;
|
|
1878
2033
|
return normalized;
|
|
1879
2034
|
}
|
|
1880
2035
|
function toReactEmailTemplateCompatibilityInput(input) {
|
|
@@ -1898,6 +2053,17 @@ function normalizeAdminEmailTemplateSendPayload(payload) {
|
|
|
1898
2053
|
copyDefinedField(normalized, payload, "user_id", "userId");
|
|
1899
2054
|
copyDefinedField(normalized, payload, "organization_id", "organizationId");
|
|
1900
2055
|
copyDefinedField(normalized, payload, "session_token", "sessionToken");
|
|
2056
|
+
copyDefinedField(normalized, payload, "attachment_failure_mode", "attachmentFailureMode");
|
|
2057
|
+
if (Object.hasOwn(payload, "attachments")) {
|
|
2058
|
+
normalized.attachments = normalizeEmailTemplateAttachmentsValue(payload.attachments);
|
|
2059
|
+
}
|
|
2060
|
+
delete normalized.templateId;
|
|
2061
|
+
delete normalized.recipientEmail;
|
|
2062
|
+
delete normalized.renderVariables;
|
|
2063
|
+
delete normalized.userId;
|
|
2064
|
+
delete normalized.organizationId;
|
|
2065
|
+
delete normalized.sessionToken;
|
|
2066
|
+
delete normalized.attachmentFailureMode;
|
|
1901
2067
|
return normalized;
|
|
1902
2068
|
}
|
|
1903
2069
|
function toSessionGuardFailure(sessionResult) {
|
|
@@ -1963,45 +2129,7 @@ function extractFetchOptions(input) {
|
|
|
1963
2129
|
};
|
|
1964
2130
|
}
|
|
1965
2131
|
function buildHeaders2(config, options) {
|
|
1966
|
-
|
|
1967
|
-
const headers = {
|
|
1968
|
-
"Content-Type": "application/json",
|
|
1969
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE2
|
|
1970
|
-
};
|
|
1971
|
-
const apiKey = options?.apiKey ?? config.apiKey;
|
|
1972
|
-
if (apiKey) {
|
|
1973
|
-
headers.apikey = apiKey;
|
|
1974
|
-
headers["x-api-key"] = apiKey;
|
|
1975
|
-
}
|
|
1976
|
-
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
1977
|
-
if (bearerToken) {
|
|
1978
|
-
headers.Authorization = `Bearer ${bearerToken}`;
|
|
1979
|
-
}
|
|
1980
|
-
const cookie = options?.cookie ?? config.cookie;
|
|
1981
|
-
if (cookie) {
|
|
1982
|
-
headers.Cookie = cookie;
|
|
1983
|
-
}
|
|
1984
|
-
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
1985
|
-
if (sessionToken) {
|
|
1986
|
-
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
1987
|
-
}
|
|
1988
|
-
const mergedExtraHeaders = {
|
|
1989
|
-
...config.headers ?? {},
|
|
1990
|
-
...options?.headers ?? {}
|
|
1991
|
-
};
|
|
1992
|
-
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
1993
|
-
if (forceNoCache && isCacheControlHeaderName2(key)) {
|
|
1994
|
-
return;
|
|
1995
|
-
}
|
|
1996
|
-
const normalized = normalizeHeaderValue2(value);
|
|
1997
|
-
if (normalized) {
|
|
1998
|
-
headers[key] = normalized;
|
|
1999
|
-
}
|
|
2000
|
-
});
|
|
2001
|
-
if (forceNoCache) {
|
|
2002
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
|
|
2003
|
-
}
|
|
2004
|
-
return headers;
|
|
2132
|
+
return buildServiceRequestHeaders("auth", SDK_HEADER_VALUE2, config, options);
|
|
2005
2133
|
}
|
|
2006
2134
|
function appendQueryParam(searchParams, key, value) {
|
|
2007
2135
|
if (value === void 0 || value === null) return;
|
|
@@ -5680,7 +5808,6 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5680
5808
|
// src/chat/module.ts
|
|
5681
5809
|
var SDK_NAME3 = "xylex-group/athena-chat";
|
|
5682
5810
|
var SDK_HEADER_VALUE3 = buildSdkHeaderValue(SDK_NAME3);
|
|
5683
|
-
var NO_CACHE_HEADER_VALUE3 = "no-cache";
|
|
5684
5811
|
var AthenaChatError = class extends Error {
|
|
5685
5812
|
status;
|
|
5686
5813
|
endpoint;
|
|
@@ -5726,9 +5853,6 @@ function normalizeWsUrl(value, label) {
|
|
|
5726
5853
|
function isRecord7(value) {
|
|
5727
5854
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5728
5855
|
}
|
|
5729
|
-
function normalizeHeaderValue3(value) {
|
|
5730
|
-
return value ? value : void 0;
|
|
5731
|
-
}
|
|
5732
5856
|
function parseResponseBody4(rawText, contentType) {
|
|
5733
5857
|
if (!rawText) {
|
|
5734
5858
|
return { parsed: null, parseFailed: false };
|
|
@@ -5800,39 +5924,7 @@ function createSocket(factory, url, protocols) {
|
|
|
5800
5924
|
}
|
|
5801
5925
|
}
|
|
5802
5926
|
function buildHeaders3(config, options) {
|
|
5803
|
-
|
|
5804
|
-
Accept: "application/json",
|
|
5805
|
-
apikey: config.apiKey,
|
|
5806
|
-
"x-api-key": config.apiKey,
|
|
5807
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE3
|
|
5808
|
-
};
|
|
5809
|
-
if (config.client || options?.client) {
|
|
5810
|
-
headers["X-Athena-Client"] = options?.client ?? config.client ?? "";
|
|
5811
|
-
}
|
|
5812
|
-
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
5813
|
-
if (typeof bearerToken === "string" && bearerToken.trim()) {
|
|
5814
|
-
headers.Authorization = bearerToken.startsWith("Bearer ") ? bearerToken : `Bearer ${bearerToken}`;
|
|
5815
|
-
}
|
|
5816
|
-
const cookie = options?.cookie ?? config.cookie;
|
|
5817
|
-
if (typeof cookie === "string" && cookie.trim()) {
|
|
5818
|
-
headers.Cookie = cookie;
|
|
5819
|
-
}
|
|
5820
|
-
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
5821
|
-
if (typeof sessionToken === "string" && sessionToken.trim()) {
|
|
5822
|
-
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
5823
|
-
}
|
|
5824
|
-
if (config.forceNoCache || options?.forceNoCache) {
|
|
5825
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE3;
|
|
5826
|
-
}
|
|
5827
|
-
for (const source of [config.headers, options?.headers]) {
|
|
5828
|
-
for (const [key, value] of Object.entries(source ?? {})) {
|
|
5829
|
-
const normalized = normalizeHeaderValue3(value);
|
|
5830
|
-
if (normalized) {
|
|
5831
|
-
headers[key] = normalized;
|
|
5832
|
-
}
|
|
5833
|
-
}
|
|
5834
|
-
}
|
|
5835
|
-
return headers;
|
|
5927
|
+
return buildServiceRequestHeaders("chat", SDK_HEADER_VALUE3, config, options);
|
|
5836
5928
|
}
|
|
5837
5929
|
function withJsonBody(init, body) {
|
|
5838
5930
|
return {
|
|
@@ -6244,6 +6336,9 @@ var AthenaClientBuilderImpl = class {
|
|
|
6244
6336
|
defaultOrganizationId;
|
|
6245
6337
|
forceNoCacheEnabled = false;
|
|
6246
6338
|
defaultHeaders;
|
|
6339
|
+
pgUriValue;
|
|
6340
|
+
jdbcUrlValue;
|
|
6341
|
+
athenaKeyValue;
|
|
6247
6342
|
authConfig;
|
|
6248
6343
|
dbUrlOverride;
|
|
6249
6344
|
gatewayUrlOverride;
|
|
@@ -6270,6 +6365,18 @@ var AthenaClientBuilderImpl = class {
|
|
|
6270
6365
|
this.defaultHeaders = headers;
|
|
6271
6366
|
return this;
|
|
6272
6367
|
}
|
|
6368
|
+
pgUri(pgUri) {
|
|
6369
|
+
this.pgUriValue = pgUri;
|
|
6370
|
+
return this;
|
|
6371
|
+
}
|
|
6372
|
+
jdbcUrl(jdbcUrl) {
|
|
6373
|
+
this.jdbcUrlValue = jdbcUrl;
|
|
6374
|
+
return this;
|
|
6375
|
+
}
|
|
6376
|
+
athenaKey(athenaKey) {
|
|
6377
|
+
this.athenaKeyValue = athenaKey;
|
|
6378
|
+
return this;
|
|
6379
|
+
}
|
|
6273
6380
|
auth(config) {
|
|
6274
6381
|
this.authConfig = mergeAuthClientConfig(this.authConfig, config);
|
|
6275
6382
|
return this;
|
|
@@ -6306,6 +6413,15 @@ var AthenaClientBuilderImpl = class {
|
|
|
6306
6413
|
if (options.headers !== void 0) {
|
|
6307
6414
|
this.defaultHeaders = mergeHeaders(this.defaultHeaders, options.headers);
|
|
6308
6415
|
}
|
|
6416
|
+
if (options.pgUri !== void 0) {
|
|
6417
|
+
this.pgUriValue = options.pgUri;
|
|
6418
|
+
}
|
|
6419
|
+
if (options.jdbcUrl !== void 0) {
|
|
6420
|
+
this.jdbcUrlValue = options.jdbcUrl;
|
|
6421
|
+
}
|
|
6422
|
+
if (options.athenaKey !== void 0) {
|
|
6423
|
+
this.athenaKeyValue = options.athenaKey;
|
|
6424
|
+
}
|
|
6309
6425
|
if (options.auth !== void 0) {
|
|
6310
6426
|
this.authConfig = mergeAuthClientConfig(this.authConfig, options.auth);
|
|
6311
6427
|
}
|
|
@@ -6357,6 +6473,9 @@ var AthenaClientBuilderImpl = class {
|
|
|
6357
6473
|
userId: this.defaultUserId,
|
|
6358
6474
|
organizationId: this.defaultOrganizationId,
|
|
6359
6475
|
forceNoCache: this.forceNoCacheEnabled,
|
|
6476
|
+
pgUri: this.pgUriValue,
|
|
6477
|
+
jdbcUrl: this.jdbcUrlValue,
|
|
6478
|
+
athenaKey: this.athenaKeyValue,
|
|
6360
6479
|
backend: this.backendConfig,
|
|
6361
6480
|
headers: this.defaultHeaders,
|
|
6362
6481
|
db: this.dbUrlOverride ? { url: this.dbUrlOverride } : void 0,
|
|
@@ -9069,10 +9188,6 @@ function resolveRequiredClientApiKey(value) {
|
|
|
9069
9188
|
}
|
|
9070
9189
|
return normalizedValue;
|
|
9071
9190
|
}
|
|
9072
|
-
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
9073
|
-
const normalizedTargetKey = targetKey.toLowerCase();
|
|
9074
|
-
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
9075
|
-
}
|
|
9076
9191
|
function mergeClientHeaders(current, next) {
|
|
9077
9192
|
if (!current && !next) {
|
|
9078
9193
|
return void 0;
|
|
@@ -9203,6 +9318,9 @@ function resolveCreateClientConfig(config) {
|
|
|
9203
9318
|
userId: config.userId,
|
|
9204
9319
|
organizationId: config.organizationId,
|
|
9205
9320
|
forceNoCache: config.forceNoCache,
|
|
9321
|
+
pgUri: config.pgUri,
|
|
9322
|
+
jdbcUrl: config.jdbcUrl,
|
|
9323
|
+
athenaKey: config.athenaKey,
|
|
9206
9324
|
backend: toBackendConfig(config.backend),
|
|
9207
9325
|
headers: config.headers,
|
|
9208
9326
|
auth: config.auth,
|
|
@@ -9219,18 +9337,6 @@ function createClientFromInput(sourceConfig) {
|
|
|
9219
9337
|
}
|
|
9220
9338
|
function createClientFromConfig(config, sourceConfig) {
|
|
9221
9339
|
const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
|
|
9222
|
-
const gatewayHeaders = {
|
|
9223
|
-
...config.headers ?? {}
|
|
9224
|
-
};
|
|
9225
|
-
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
|
|
9226
|
-
gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
|
|
9227
|
-
}
|
|
9228
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
|
|
9229
|
-
gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
|
|
9230
|
-
}
|
|
9231
|
-
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
|
|
9232
|
-
gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9233
|
-
}
|
|
9234
9340
|
const gateway = createAthenaGatewayClient({
|
|
9235
9341
|
baseUrl: config.baseUrl,
|
|
9236
9342
|
apiKey: config.apiKey,
|
|
@@ -9238,8 +9344,14 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9238
9344
|
userId: config.userId,
|
|
9239
9345
|
organizationId: config.organizationId,
|
|
9240
9346
|
forceNoCache: config.forceNoCache,
|
|
9347
|
+
pgUri: config.pgUri,
|
|
9348
|
+
jdbcUrl: config.jdbcUrl,
|
|
9349
|
+
athenaKey: config.athenaKey,
|
|
9241
9350
|
backend: config.backend,
|
|
9242
|
-
|
|
9351
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9352
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9353
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9354
|
+
headers: config.headers
|
|
9243
9355
|
});
|
|
9244
9356
|
const formatGatewayResult = createResultFormatter(config.experimental);
|
|
9245
9357
|
const queryTracer = createQueryTracer(config.experimental);
|
|
@@ -9297,6 +9409,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9297
9409
|
const chat = createChatModule({
|
|
9298
9410
|
baseUrl: config.chatUrl,
|
|
9299
9411
|
apiKey: config.apiKey,
|
|
9412
|
+
athenaKey: config.athenaKey,
|
|
9300
9413
|
client: config.client,
|
|
9301
9414
|
headers: config.headers,
|
|
9302
9415
|
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
@@ -9333,48 +9446,28 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9333
9446
|
return path.startsWith("/") ? path : `/${path}`;
|
|
9334
9447
|
})();
|
|
9335
9448
|
const targetUrl = options.url ? `${normalizedBaseUrl}${toRequestQueryString(options.query)}` : `${normalizedBaseUrl}${normalizedPath}${toRequestQueryString(options.query)}`;
|
|
9336
|
-
const
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9355
|
-
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
}
|
|
9359
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9360
|
-
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9361
|
-
}
|
|
9362
|
-
} else {
|
|
9363
|
-
const authApiKey = normalizedAuthConfig?.apiKey ?? config.apiKey;
|
|
9364
|
-
if (authApiKey && !hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
9365
|
-
headers.apikey = headers.apikey ?? authApiKey;
|
|
9366
|
-
headers["x-api-key"] = headers["x-api-key"] ?? authApiKey;
|
|
9367
|
-
}
|
|
9368
|
-
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
9369
|
-
headers.Authorization = `Bearer ${normalizedAuthConfig.bearerToken}`;
|
|
9370
|
-
}
|
|
9371
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9372
|
-
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9373
|
-
}
|
|
9374
|
-
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
9375
|
-
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9376
|
-
}
|
|
9377
|
-
}
|
|
9449
|
+
const requestProfile = service === "auth" ? "auth" : service === "chat" ? "chat" : service === "storage" ? "storage" : "gateway";
|
|
9450
|
+
const headers = buildAthenaRequestHeaders({
|
|
9451
|
+
profile: requestProfile,
|
|
9452
|
+
sdkHeaderValue: buildSdkHeaderValue(SDK_NAME4),
|
|
9453
|
+
apiKey: options.apiKey ?? (service === "auth" ? normalizedAuthConfig?.apiKey ?? config.apiKey : config.apiKey),
|
|
9454
|
+
athenaKey: options.athenaKey ?? config.athenaKey,
|
|
9455
|
+
client: config.client,
|
|
9456
|
+
userId: config.userId,
|
|
9457
|
+
organizationId: config.organizationId,
|
|
9458
|
+
backend: config.backend,
|
|
9459
|
+
pgUri: config.pgUri,
|
|
9460
|
+
jdbcUrl: config.jdbcUrl,
|
|
9461
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9462
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9463
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9464
|
+
forceNoCache: config.forceNoCache,
|
|
9465
|
+
configHeaders: config.headers,
|
|
9466
|
+
callHeaders: options.headers,
|
|
9467
|
+
accept: service === "chat" ? "application/json" : void 0,
|
|
9468
|
+
contentType: service === "auth" || service === "db" || service === "storage" ? "application/json" : void 0,
|
|
9469
|
+
stripNulls: service === "db" ? true : void 0
|
|
9470
|
+
});
|
|
9378
9471
|
const shouldSendJsonBody = options.body !== void 0 && options.body !== null && !(options.body instanceof FormData) && !(options.body instanceof Blob) && !(options.body instanceof URLSearchParams) && !(options.body instanceof ArrayBuffer) && !ArrayBuffer.isView(options.body) && typeof options.body !== "string";
|
|
9379
9472
|
if (shouldSendJsonBody && !hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
9380
9473
|
headers["Content-Type"] = "application/json";
|