@xylex-group/athena 2.11.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 +1 -1
- package/dist/browser.cjs +296 -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 +296 -240
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +269 -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 +269 -240
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-DD_UeF3Q.d.ts → client-C3x75Zgn.d.cts} +20 -9
- package/dist/{client-WqBuu60O.d.cts → client-QUbAs7E8.d.ts} +20 -9
- package/dist/index.cjs +296 -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 +296 -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-DRkIHtY-.d.ts → module-CW3tWJ10.d.ts} +5 -4
- package/dist/{module-BFMyVmwX.d.cts → module-Cxcurfes.d.cts} +5 -4
- package/dist/next/client.cjs +296 -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 +296 -240
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +296 -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 +296 -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-GPAprhBb.d.ts → shared-0Kdc74lu.d.ts} +2 -2
- package/dist/{shared-B1ueL-Ox.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 +1 -1
- package/dist/types-BeZIHduP.d.cts +0 -428
- package/dist/types-BeZIHduP.d.ts +0 -428
package/dist/cli/index.cjs
CHANGED
|
@@ -2002,42 +2002,31 @@ var getSessionCookie = (request2, config) => {
|
|
|
2002
2002
|
return null;
|
|
2003
2003
|
};
|
|
2004
2004
|
|
|
2005
|
-
//
|
|
2006
|
-
var package_default = {
|
|
2007
|
-
version: "2.11.0"
|
|
2008
|
-
};
|
|
2009
|
-
|
|
2010
|
-
// src/sdk-version.ts
|
|
2011
|
-
var PACKAGE_VERSION = package_default.version;
|
|
2012
|
-
function buildSdkHeaderValue(sdkName) {
|
|
2013
|
-
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
// src/gateway/client.ts
|
|
2017
|
-
var DEFAULT_CLIENT = "railway_direct";
|
|
2018
|
-
var SDK_NAME = "xylex-group/athena";
|
|
2019
|
-
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
2005
|
+
// src/utils/athena-request-headers.ts
|
|
2020
2006
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
}
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
}
|
|
2007
|
+
var API_KEY_HEADER_CANDIDATES = ["x-api-key", "apikey"];
|
|
2008
|
+
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
2009
|
+
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
2010
|
+
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
2011
|
+
var CLIENT_HEADER_CANDIDATES = ["X-Athena-Client", "x-athena-client"];
|
|
2012
|
+
var PG_URI_HEADER_CANDIDATES = ["x-pg-uri"];
|
|
2013
|
+
var JDBC_URI_HEADER_CANDIDATES = ["x-athena-jdbc-url", "x-jdbc-url"];
|
|
2014
|
+
var PROFILE_RULES = {
|
|
2015
|
+
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
2016
|
+
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
2017
|
+
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
2018
|
+
auth: { apiKeys: true, routing: false, authMirror: false, authBearer: true, contentType: true },
|
|
2019
|
+
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
2020
|
+
};
|
|
2036
2021
|
function normalizeHeaderValue(value) {
|
|
2037
2022
|
return value ? value : void 0;
|
|
2038
2023
|
}
|
|
2039
|
-
function
|
|
2040
|
-
return
|
|
2024
|
+
function mergeExtraHeaders(configHeaders, callHeaders) {
|
|
2025
|
+
return { ...configHeaders ?? {}, ...callHeaders ?? {} };
|
|
2026
|
+
}
|
|
2027
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
2028
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
2029
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
2041
2030
|
}
|
|
2042
2031
|
function resolveHeaderValue(headers, candidates) {
|
|
2043
2032
|
for (const candidate of candidates) {
|
|
@@ -2054,13 +2043,20 @@ function resolveHeaderValue(headers, candidates) {
|
|
|
2054
2043
|
}
|
|
2055
2044
|
return void 0;
|
|
2056
2045
|
}
|
|
2046
|
+
function isCacheControlHeaderName(name) {
|
|
2047
|
+
return name.toLowerCase() === "cache-control";
|
|
2048
|
+
}
|
|
2049
|
+
function normalizeBearerToken(value) {
|
|
2050
|
+
const trimmed = value.trim();
|
|
2051
|
+
const match = trimmed.match(/^Bearer\s+(.+)$/i);
|
|
2052
|
+
return match?.[1]?.trim() ?? trimmed;
|
|
2053
|
+
}
|
|
2057
2054
|
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
2058
2055
|
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
2059
2056
|
if (!authorization) {
|
|
2060
2057
|
return void 0;
|
|
2061
2058
|
}
|
|
2062
|
-
const
|
|
2063
|
-
const token = match?.[1]?.trim();
|
|
2059
|
+
const token = normalizeBearerToken(authorization);
|
|
2064
2060
|
return token ? token : void 0;
|
|
2065
2061
|
}
|
|
2066
2062
|
function resolveSessionTokenFromCookieHeader(headers) {
|
|
@@ -2070,6 +2066,207 @@ function resolveSessionTokenFromCookieHeader(headers) {
|
|
|
2070
2066
|
}
|
|
2071
2067
|
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
2072
2068
|
}
|
|
2069
|
+
function resolveBackendType(backend) {
|
|
2070
|
+
if (!backend) {
|
|
2071
|
+
return void 0;
|
|
2072
|
+
}
|
|
2073
|
+
return typeof backend === "string" ? backend : backend.type;
|
|
2074
|
+
}
|
|
2075
|
+
function resolveRequestHeaderOverrides(config, options, defaults) {
|
|
2076
|
+
return {
|
|
2077
|
+
apiKey: options?.apiKey ?? config.apiKey,
|
|
2078
|
+
athenaKey: options?.athenaKey ?? config.athenaKey,
|
|
2079
|
+
client: options?.client ?? config.client ?? defaults?.client,
|
|
2080
|
+
userId: options?.userId ?? config.userId,
|
|
2081
|
+
organizationId: options?.organizationId ?? config.organizationId,
|
|
2082
|
+
backend: options?.backend ?? config.backend,
|
|
2083
|
+
publishEvent: options?.publishEvent ?? config.publishEvent,
|
|
2084
|
+
stripNulls: options?.stripNulls ?? config.stripNulls ?? defaults?.stripNulls,
|
|
2085
|
+
bearerToken: options?.bearerToken ?? config.bearerToken,
|
|
2086
|
+
cookie: options?.cookie ?? config.cookie,
|
|
2087
|
+
sessionToken: options?.sessionToken ?? config.sessionToken,
|
|
2088
|
+
pgUri: options?.pgUri ?? config.pgUri,
|
|
2089
|
+
jdbcUrl: options?.jdbcUrl ?? config.jdbcUrl,
|
|
2090
|
+
forceNoCache: Boolean(config.forceNoCache || options?.forceNoCache),
|
|
2091
|
+
configHeaders: config.headers,
|
|
2092
|
+
callHeaders: options?.headers
|
|
2093
|
+
};
|
|
2094
|
+
}
|
|
2095
|
+
function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, extras) {
|
|
2096
|
+
const rules = PROFILE_RULES[profile];
|
|
2097
|
+
return buildAthenaRequestHeaders({
|
|
2098
|
+
profile,
|
|
2099
|
+
sdkHeaderValue,
|
|
2100
|
+
...resolveRequestHeaderOverrides(config, options, {
|
|
2101
|
+
client: extras?.client ?? void 0,
|
|
2102
|
+
stripNulls: extras?.stripNulls ?? (rules.stripNullsDefault ? true : void 0)
|
|
2103
|
+
}),
|
|
2104
|
+
contentType: extras?.contentType ?? (rules.contentType ? "application/json" : void 0),
|
|
2105
|
+
accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
|
|
2106
|
+
});
|
|
2107
|
+
}
|
|
2108
|
+
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
2109
|
+
if (apiKey) {
|
|
2110
|
+
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
2111
|
+
headers.apikey = apiKey;
|
|
2112
|
+
}
|
|
2113
|
+
if (!hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
2114
|
+
headers["x-api-key"] = apiKey;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
2118
|
+
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
2119
|
+
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
2123
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
2124
|
+
const rules = PROFILE_RULES[input.profile];
|
|
2125
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
2126
|
+
if (explicitCookie) {
|
|
2127
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
2128
|
+
}
|
|
2129
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
2130
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
2131
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
2132
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
2133
|
+
headers.Cookie = explicitCookie;
|
|
2134
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
2135
|
+
headers.Cookie = cookieFromHeaders;
|
|
2136
|
+
}
|
|
2137
|
+
const explicitBearerToken = (() => {
|
|
2138
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
2139
|
+
if (configured) {
|
|
2140
|
+
return normalizeBearerToken(configured);
|
|
2141
|
+
}
|
|
2142
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
2143
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
2144
|
+
})();
|
|
2145
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
2146
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
2147
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
2148
|
+
}
|
|
2149
|
+
if (rules.authMirror) {
|
|
2150
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
2151
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
2152
|
+
}
|
|
2153
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
2154
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
2155
|
+
}
|
|
2156
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
2157
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
2161
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
2162
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
2163
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
2164
|
+
headers["x-pg-uri"] = pgUri;
|
|
2165
|
+
}
|
|
2166
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
2167
|
+
if (jdbcUrl) {
|
|
2168
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
2169
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
2170
|
+
}
|
|
2171
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
2172
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
function buildAthenaRequestHeaders(input) {
|
|
2177
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
2178
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
2179
|
+
const rules = PROFILE_RULES[input.profile];
|
|
2180
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
2181
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
2182
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
2183
|
+
const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
2184
|
+
const headers = {
|
|
2185
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
2186
|
+
};
|
|
2187
|
+
if (rules.contentType) {
|
|
2188
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
2189
|
+
}
|
|
2190
|
+
if (input.accept ?? rules.accept) {
|
|
2191
|
+
headers.Accept = input.accept ?? "application/json";
|
|
2192
|
+
}
|
|
2193
|
+
if (rules.routing) {
|
|
2194
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
2195
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
2196
|
+
}
|
|
2197
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
2198
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
2199
|
+
}
|
|
2200
|
+
if (finalClient) {
|
|
2201
|
+
headers["X-Athena-Client"] = finalClient;
|
|
2202
|
+
}
|
|
2203
|
+
const backendType = resolveBackendType(input.backend);
|
|
2204
|
+
if (backendType) {
|
|
2205
|
+
headers["X-Backend-Type"] = backendType;
|
|
2206
|
+
}
|
|
2207
|
+
if (typeof input.stripNulls === "boolean") {
|
|
2208
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
2209
|
+
} else if (rules.stripNullsDefault) {
|
|
2210
|
+
headers["X-Strip-Nulls"] = "true";
|
|
2211
|
+
}
|
|
2212
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
2213
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
2217
|
+
applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
|
|
2218
|
+
}
|
|
2219
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
2220
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
2221
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
2222
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
2223
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
2224
|
+
return;
|
|
2225
|
+
}
|
|
2226
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
const normalized = normalizeHeaderValue(value);
|
|
2230
|
+
if (normalized) {
|
|
2231
|
+
headers[key] = normalized;
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
if (forceNoCache) {
|
|
2235
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
2236
|
+
}
|
|
2237
|
+
return headers;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
// package.json
|
|
2241
|
+
var package_default = {
|
|
2242
|
+
version: "2.12.0"
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
// src/sdk-version.ts
|
|
2246
|
+
var PACKAGE_VERSION = package_default.version;
|
|
2247
|
+
function buildSdkHeaderValue(sdkName) {
|
|
2248
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
// src/gateway/client.ts
|
|
2252
|
+
var DEFAULT_CLIENT = "railway_direct";
|
|
2253
|
+
var SDK_NAME = "xylex-group/athena";
|
|
2254
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
2255
|
+
function parseResponseBody(rawText, contentType) {
|
|
2256
|
+
if (!rawText) {
|
|
2257
|
+
return { parsed: null, parseFailed: false };
|
|
2258
|
+
}
|
|
2259
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
2260
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
2261
|
+
if (!looksJson) {
|
|
2262
|
+
return { parsed: rawText, parseFailed: false };
|
|
2263
|
+
}
|
|
2264
|
+
try {
|
|
2265
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
2266
|
+
} catch {
|
|
2267
|
+
return { parsed: rawText, parseFailed: true };
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2073
2270
|
function isRecord2(value) {
|
|
2074
2271
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2075
2272
|
}
|
|
@@ -2196,71 +2393,10 @@ function buildRpcGetEndpoint(payload) {
|
|
|
2196
2393
|
return withQuery;
|
|
2197
2394
|
}
|
|
2198
2395
|
function buildHeaders(config, options) {
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
...config.headers ?? {},
|
|
2203
|
-
...options?.headers ?? {}
|
|
2204
|
-
};
|
|
2205
|
-
const headerClient = extraHeaders["x-athena-client"] ?? extraHeaders["X-Athena-Client"];
|
|
2206
|
-
const finalClient = options?.client ?? config.client ?? (typeof headerClient === "string" ? headerClient : void 0) ?? DEFAULT_CLIENT;
|
|
2207
|
-
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
2208
|
-
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
2209
|
-
const headers = {
|
|
2210
|
-
"Content-Type": "application/json",
|
|
2211
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE
|
|
2212
|
-
};
|
|
2213
|
-
if (options?.userId ?? config.userId) {
|
|
2214
|
-
headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
|
|
2215
|
-
}
|
|
2216
|
-
if (options?.organizationId ?? config.organizationId) {
|
|
2217
|
-
headers["X-Organization-Id"] = options?.organizationId ?? config.organizationId ?? "";
|
|
2218
|
-
}
|
|
2219
|
-
if (finalClient) {
|
|
2220
|
-
headers["X-Athena-Client"] = finalClient;
|
|
2221
|
-
}
|
|
2222
|
-
const finalBackend = options?.backend ?? config.backend;
|
|
2223
|
-
if (finalBackend) {
|
|
2224
|
-
const type = typeof finalBackend === "string" ? finalBackend : finalBackend.type;
|
|
2225
|
-
if (type) headers["X-Backend-Type"] = type;
|
|
2226
|
-
}
|
|
2227
|
-
if (typeof mergedStripNulls === "boolean") {
|
|
2228
|
-
headers["X-Strip-Nulls"] = mergedStripNulls ? "true" : "false";
|
|
2229
|
-
}
|
|
2230
|
-
if (finalPublishEvent) {
|
|
2231
|
-
headers["X-Publish-Event"] = finalPublishEvent;
|
|
2232
|
-
}
|
|
2233
|
-
if (finalApiKey) {
|
|
2234
|
-
headers["apikey"] = finalApiKey;
|
|
2235
|
-
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
2236
|
-
}
|
|
2237
|
-
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
2238
|
-
"X-Athena-Auth-Session-Token"
|
|
2239
|
-
]);
|
|
2240
|
-
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
2241
|
-
if (derivedSessionToken) {
|
|
2242
|
-
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
2243
|
-
}
|
|
2244
|
-
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
2245
|
-
"X-Athena-Auth-Bearer-Token"
|
|
2246
|
-
]);
|
|
2247
|
-
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
2248
|
-
if (derivedBearerToken) {
|
|
2249
|
-
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
2250
|
-
}
|
|
2251
|
-
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
2252
|
-
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
2253
|
-
if (athenaClientKeys.includes(key)) return;
|
|
2254
|
-
if (forceNoCache && isCacheControlHeaderName(key)) return;
|
|
2255
|
-
const normalized = normalizeHeaderValue(value);
|
|
2256
|
-
if (normalized) {
|
|
2257
|
-
headers[key] = normalized;
|
|
2258
|
-
}
|
|
2396
|
+
return buildServiceRequestHeaders("gateway", SDK_HEADER_VALUE, config, options, {
|
|
2397
|
+
client: options?.client ?? config.client ?? DEFAULT_CLIENT,
|
|
2398
|
+
stripNulls: options?.stripNulls ?? true
|
|
2259
2399
|
});
|
|
2260
|
-
if (forceNoCache) {
|
|
2261
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
2262
|
-
}
|
|
2263
|
-
return headers;
|
|
2264
2400
|
}
|
|
2265
2401
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
2266
2402
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2917,19 +3053,12 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
|
|
|
2917
3053
|
var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
|
|
2918
3054
|
var SDK_NAME2 = "xylex-group/athena-auth";
|
|
2919
3055
|
var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
|
|
2920
|
-
var NO_CACHE_HEADER_VALUE2 = "no-cache";
|
|
2921
3056
|
function normalizeBaseUrl(baseUrl) {
|
|
2922
3057
|
return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
|
|
2923
3058
|
}
|
|
2924
3059
|
function isRecord4(value) {
|
|
2925
3060
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2926
3061
|
}
|
|
2927
|
-
function normalizeHeaderValue2(value) {
|
|
2928
|
-
return value ? value : void 0;
|
|
2929
|
-
}
|
|
2930
|
-
function isCacheControlHeaderName2(name) {
|
|
2931
|
-
return name.toLowerCase() === "cache-control";
|
|
2932
|
-
}
|
|
2933
3062
|
function parseResponseBody2(rawText, contentType) {
|
|
2934
3063
|
if (!rawText) {
|
|
2935
3064
|
return { parsed: null, parseFailed: false };
|
|
@@ -3129,45 +3258,7 @@ function extractFetchOptions(input) {
|
|
|
3129
3258
|
};
|
|
3130
3259
|
}
|
|
3131
3260
|
function buildHeaders2(config, options) {
|
|
3132
|
-
|
|
3133
|
-
const headers = {
|
|
3134
|
-
"Content-Type": "application/json",
|
|
3135
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE2
|
|
3136
|
-
};
|
|
3137
|
-
const apiKey = options?.apiKey ?? config.apiKey;
|
|
3138
|
-
if (apiKey) {
|
|
3139
|
-
headers.apikey = apiKey;
|
|
3140
|
-
headers["x-api-key"] = apiKey;
|
|
3141
|
-
}
|
|
3142
|
-
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
3143
|
-
if (bearerToken) {
|
|
3144
|
-
headers.Authorization = `Bearer ${bearerToken}`;
|
|
3145
|
-
}
|
|
3146
|
-
const cookie = options?.cookie ?? config.cookie;
|
|
3147
|
-
if (cookie) {
|
|
3148
|
-
headers.Cookie = cookie;
|
|
3149
|
-
}
|
|
3150
|
-
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
3151
|
-
if (sessionToken) {
|
|
3152
|
-
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
3153
|
-
}
|
|
3154
|
-
const mergedExtraHeaders = {
|
|
3155
|
-
...config.headers ?? {},
|
|
3156
|
-
...options?.headers ?? {}
|
|
3157
|
-
};
|
|
3158
|
-
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
3159
|
-
if (forceNoCache && isCacheControlHeaderName2(key)) {
|
|
3160
|
-
return;
|
|
3161
|
-
}
|
|
3162
|
-
const normalized = normalizeHeaderValue2(value);
|
|
3163
|
-
if (normalized) {
|
|
3164
|
-
headers[key] = normalized;
|
|
3165
|
-
}
|
|
3166
|
-
});
|
|
3167
|
-
if (forceNoCache) {
|
|
3168
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
|
|
3169
|
-
}
|
|
3170
|
-
return headers;
|
|
3261
|
+
return buildServiceRequestHeaders("auth", SDK_HEADER_VALUE2, config, options);
|
|
3171
3262
|
}
|
|
3172
3263
|
function appendQueryParam(searchParams, key, value) {
|
|
3173
3264
|
if (value === void 0 || value === null) return;
|
|
@@ -6293,7 +6384,6 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6293
6384
|
// src/chat/module.ts
|
|
6294
6385
|
var SDK_NAME3 = "xylex-group/athena-chat";
|
|
6295
6386
|
var SDK_HEADER_VALUE3 = buildSdkHeaderValue(SDK_NAME3);
|
|
6296
|
-
var NO_CACHE_HEADER_VALUE3 = "no-cache";
|
|
6297
6387
|
var AthenaChatError = class extends Error {
|
|
6298
6388
|
status;
|
|
6299
6389
|
endpoint;
|
|
@@ -6339,9 +6429,6 @@ function normalizeWsUrl(value, label) {
|
|
|
6339
6429
|
function isRecord7(value) {
|
|
6340
6430
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6341
6431
|
}
|
|
6342
|
-
function normalizeHeaderValue3(value) {
|
|
6343
|
-
return value ? value : void 0;
|
|
6344
|
-
}
|
|
6345
6432
|
function parseResponseBody4(rawText, contentType) {
|
|
6346
6433
|
if (!rawText) {
|
|
6347
6434
|
return { parsed: null, parseFailed: false };
|
|
@@ -6413,39 +6500,7 @@ function createSocket(factory, url, protocols) {
|
|
|
6413
6500
|
}
|
|
6414
6501
|
}
|
|
6415
6502
|
function buildHeaders3(config, options) {
|
|
6416
|
-
|
|
6417
|
-
Accept: "application/json",
|
|
6418
|
-
apikey: config.apiKey,
|
|
6419
|
-
"x-api-key": config.apiKey,
|
|
6420
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE3
|
|
6421
|
-
};
|
|
6422
|
-
if (config.client || options?.client) {
|
|
6423
|
-
headers["X-Athena-Client"] = options?.client ?? config.client ?? "";
|
|
6424
|
-
}
|
|
6425
|
-
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
6426
|
-
if (typeof bearerToken === "string" && bearerToken.trim()) {
|
|
6427
|
-
headers.Authorization = bearerToken.startsWith("Bearer ") ? bearerToken : `Bearer ${bearerToken}`;
|
|
6428
|
-
}
|
|
6429
|
-
const cookie = options?.cookie ?? config.cookie;
|
|
6430
|
-
if (typeof cookie === "string" && cookie.trim()) {
|
|
6431
|
-
headers.Cookie = cookie;
|
|
6432
|
-
}
|
|
6433
|
-
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
6434
|
-
if (typeof sessionToken === "string" && sessionToken.trim()) {
|
|
6435
|
-
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
6436
|
-
}
|
|
6437
|
-
if (config.forceNoCache || options?.forceNoCache) {
|
|
6438
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE3;
|
|
6439
|
-
}
|
|
6440
|
-
for (const source of [config.headers, options?.headers]) {
|
|
6441
|
-
for (const [key, value] of Object.entries(source ?? {})) {
|
|
6442
|
-
const normalized = normalizeHeaderValue3(value);
|
|
6443
|
-
if (normalized) {
|
|
6444
|
-
headers[key] = normalized;
|
|
6445
|
-
}
|
|
6446
|
-
}
|
|
6447
|
-
}
|
|
6448
|
-
return headers;
|
|
6503
|
+
return buildServiceRequestHeaders("chat", SDK_HEADER_VALUE3, config, options);
|
|
6449
6504
|
}
|
|
6450
6505
|
function withJsonBody(init, body) {
|
|
6451
6506
|
return {
|
|
@@ -9439,10 +9494,6 @@ function resolveRequiredClientApiKey(value) {
|
|
|
9439
9494
|
}
|
|
9440
9495
|
return normalizedValue;
|
|
9441
9496
|
}
|
|
9442
|
-
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
9443
|
-
const normalizedTargetKey = targetKey.toLowerCase();
|
|
9444
|
-
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
9445
|
-
}
|
|
9446
9497
|
function mergeClientHeaders(current, next) {
|
|
9447
9498
|
if (!current && !next) {
|
|
9448
9499
|
return void 0;
|
|
@@ -9573,6 +9624,9 @@ function resolveCreateClientConfig(config) {
|
|
|
9573
9624
|
userId: config.userId,
|
|
9574
9625
|
organizationId: config.organizationId,
|
|
9575
9626
|
forceNoCache: config.forceNoCache,
|
|
9627
|
+
pgUri: config.pgUri,
|
|
9628
|
+
jdbcUrl: config.jdbcUrl,
|
|
9629
|
+
athenaKey: config.athenaKey,
|
|
9576
9630
|
backend: toBackendConfig(config.backend),
|
|
9577
9631
|
headers: config.headers,
|
|
9578
9632
|
auth: config.auth,
|
|
@@ -9589,18 +9643,6 @@ function createClientFromInput(sourceConfig) {
|
|
|
9589
9643
|
}
|
|
9590
9644
|
function createClientFromConfig(config, sourceConfig) {
|
|
9591
9645
|
const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
|
|
9592
|
-
const gatewayHeaders = {
|
|
9593
|
-
...config.headers ?? {}
|
|
9594
|
-
};
|
|
9595
|
-
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
|
|
9596
|
-
gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
|
|
9597
|
-
}
|
|
9598
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
|
|
9599
|
-
gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
|
|
9600
|
-
}
|
|
9601
|
-
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
|
|
9602
|
-
gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9603
|
-
}
|
|
9604
9646
|
const gateway = createAthenaGatewayClient({
|
|
9605
9647
|
baseUrl: config.baseUrl,
|
|
9606
9648
|
apiKey: config.apiKey,
|
|
@@ -9608,8 +9650,14 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9608
9650
|
userId: config.userId,
|
|
9609
9651
|
organizationId: config.organizationId,
|
|
9610
9652
|
forceNoCache: config.forceNoCache,
|
|
9653
|
+
pgUri: config.pgUri,
|
|
9654
|
+
jdbcUrl: config.jdbcUrl,
|
|
9655
|
+
athenaKey: config.athenaKey,
|
|
9611
9656
|
backend: config.backend,
|
|
9612
|
-
|
|
9657
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9658
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9659
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9660
|
+
headers: config.headers
|
|
9613
9661
|
});
|
|
9614
9662
|
const formatGatewayResult = createResultFormatter(config.experimental);
|
|
9615
9663
|
const queryTracer = createQueryTracer(config.experimental);
|
|
@@ -9667,6 +9715,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9667
9715
|
const chat = createChatModule({
|
|
9668
9716
|
baseUrl: config.chatUrl,
|
|
9669
9717
|
apiKey: config.apiKey,
|
|
9718
|
+
athenaKey: config.athenaKey,
|
|
9670
9719
|
client: config.client,
|
|
9671
9720
|
headers: config.headers,
|
|
9672
9721
|
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
@@ -9703,48 +9752,28 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9703
9752
|
return path.startsWith("/") ? path : `/${path}`;
|
|
9704
9753
|
})();
|
|
9705
9754
|
const targetUrl = options.url ? `${normalizedBaseUrl}${toRequestQueryString(options.query)}` : `${normalizedBaseUrl}${normalizedPath}${toRequestQueryString(options.query)}`;
|
|
9706
|
-
const
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
}
|
|
9729
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9730
|
-
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9731
|
-
}
|
|
9732
|
-
} else {
|
|
9733
|
-
const authApiKey = normalizedAuthConfig?.apiKey ?? config.apiKey;
|
|
9734
|
-
if (authApiKey && !hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
9735
|
-
headers.apikey = headers.apikey ?? authApiKey;
|
|
9736
|
-
headers["x-api-key"] = headers["x-api-key"] ?? authApiKey;
|
|
9737
|
-
}
|
|
9738
|
-
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
9739
|
-
headers.Authorization = `Bearer ${normalizedAuthConfig.bearerToken}`;
|
|
9740
|
-
}
|
|
9741
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9742
|
-
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9743
|
-
}
|
|
9744
|
-
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
9745
|
-
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9746
|
-
}
|
|
9747
|
-
}
|
|
9755
|
+
const requestProfile = service === "auth" ? "auth" : service === "chat" ? "chat" : service === "storage" ? "storage" : "gateway";
|
|
9756
|
+
const headers = buildAthenaRequestHeaders({
|
|
9757
|
+
profile: requestProfile,
|
|
9758
|
+
sdkHeaderValue: buildSdkHeaderValue(SDK_NAME4),
|
|
9759
|
+
apiKey: options.apiKey ?? (service === "auth" ? normalizedAuthConfig?.apiKey ?? config.apiKey : config.apiKey),
|
|
9760
|
+
athenaKey: options.athenaKey ?? config.athenaKey,
|
|
9761
|
+
client: config.client,
|
|
9762
|
+
userId: config.userId,
|
|
9763
|
+
organizationId: config.organizationId,
|
|
9764
|
+
backend: config.backend,
|
|
9765
|
+
pgUri: config.pgUri,
|
|
9766
|
+
jdbcUrl: config.jdbcUrl,
|
|
9767
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9768
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9769
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9770
|
+
forceNoCache: config.forceNoCache,
|
|
9771
|
+
configHeaders: config.headers,
|
|
9772
|
+
callHeaders: options.headers,
|
|
9773
|
+
accept: service === "chat" ? "application/json" : void 0,
|
|
9774
|
+
contentType: service === "auth" || service === "db" || service === "storage" ? "application/json" : void 0,
|
|
9775
|
+
stripNulls: service === "db" ? true : void 0
|
|
9776
|
+
});
|
|
9748
9777
|
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";
|
|
9749
9778
|
if (shouldSendJsonBody && !hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
9750
9779
|
headers["Content-Type"] = "application/json";
|