@xylex-group/athena 2.11.0 → 2.12.1
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 +299 -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 +299 -240
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +272 -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 +272 -240
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-DD_UeF3Q.d.ts → client-CMtx5P4D.d.cts} +20 -9
- package/dist/{client-WqBuu60O.d.cts → client-Dre8H24u.d.ts} +20 -9
- package/dist/index.cjs +299 -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 +299 -240
- package/dist/index.js.map +1 -1
- package/dist/{model-form-ByvyyvxB.d.ts → model-form-CU0mWrF9.d.ts} +2 -1
- package/dist/{model-form-DACdBLYG.d.cts → model-form-DfTi8-D1.d.cts} +2 -1
- package/dist/{module-DRkIHtY-.d.ts → module-DBGmbIuh.d.ts} +5 -4
- package/dist/{module-BFMyVmwX.d.cts → module-GoijrBXV.d.cts} +5 -4
- package/dist/next/client.cjs +299 -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 +299 -240
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +299 -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 +299 -240
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-DZMsPxUg.d.ts → pipeline-DrjU2vNA.d.ts} +1 -1
- package/dist/{pipeline-CmUZsXsi.d.cts → pipeline-c7Gdm0qv.d.cts} +1 -1
- package/dist/react.cjs +237 -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 +237 -98
- package/dist/react.js.map +1 -1
- package/dist/{shared-B1ueL-Ox.d.cts → shared-DZSGAmXs.d.cts} +2 -2
- package/dist/{shared-GPAprhBb.d.ts → shared-MMnVBBfy.d.ts} +2 -2
- package/dist/{types-CRjDwmtJ.d.ts → types-BLizCLd1.d.cts} +2 -1
- package/dist/types-BRUHGXo2.d.cts +236 -0
- package/dist/types-BRUHGXo2.d.ts +236 -0
- package/dist/types-Bez4HSbI.d.cts +204 -0
- package/dist/{types-C-YvfgYh.d.cts → types-DRRb0Fd0.d.ts} +2 -1
- package/dist/types-kPaHUqUa.d.ts +204 -0
- package/dist/utils.cjs +279 -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 +272 -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", "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,210 @@ 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 (!Object.hasOwn(headers, "x-api-key")) {
|
|
2114
|
+
headers["x-api-key"] = apiKey;
|
|
2115
|
+
}
|
|
2116
|
+
if (!Object.hasOwn(headers, "X-Api-Key")) {
|
|
2117
|
+
headers["X-Api-Key"] = apiKey;
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
2121
|
+
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
2122
|
+
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
2126
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
2127
|
+
const rules = PROFILE_RULES[input.profile];
|
|
2128
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
2129
|
+
if (explicitCookie) {
|
|
2130
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
2131
|
+
}
|
|
2132
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
2133
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
2134
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
2135
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
2136
|
+
headers.Cookie = explicitCookie;
|
|
2137
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
2138
|
+
headers.Cookie = cookieFromHeaders;
|
|
2139
|
+
}
|
|
2140
|
+
const explicitBearerToken = (() => {
|
|
2141
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
2142
|
+
if (configured) {
|
|
2143
|
+
return normalizeBearerToken(configured);
|
|
2144
|
+
}
|
|
2145
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
2146
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
2147
|
+
})();
|
|
2148
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
2149
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
2150
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
2151
|
+
}
|
|
2152
|
+
if (rules.authMirror) {
|
|
2153
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
2154
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
2155
|
+
}
|
|
2156
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
2157
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
2158
|
+
}
|
|
2159
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
2160
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
2164
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
2165
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
2166
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
2167
|
+
headers["x-pg-uri"] = pgUri;
|
|
2168
|
+
}
|
|
2169
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
2170
|
+
if (jdbcUrl) {
|
|
2171
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
2172
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
2173
|
+
}
|
|
2174
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
2175
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
function buildAthenaRequestHeaders(input) {
|
|
2180
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
2181
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
2182
|
+
const rules = PROFILE_RULES[input.profile];
|
|
2183
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
2184
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
2185
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
2186
|
+
const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
2187
|
+
const headers = {
|
|
2188
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
2189
|
+
};
|
|
2190
|
+
if (rules.contentType) {
|
|
2191
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
2192
|
+
}
|
|
2193
|
+
if (input.accept ?? rules.accept) {
|
|
2194
|
+
headers.Accept = input.accept ?? "application/json";
|
|
2195
|
+
}
|
|
2196
|
+
if (rules.routing) {
|
|
2197
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
2198
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
2199
|
+
}
|
|
2200
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
2201
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
2202
|
+
}
|
|
2203
|
+
if (finalClient) {
|
|
2204
|
+
headers["X-Athena-Client"] = finalClient;
|
|
2205
|
+
}
|
|
2206
|
+
const backendType = resolveBackendType(input.backend);
|
|
2207
|
+
if (backendType) {
|
|
2208
|
+
headers["X-Backend-Type"] = backendType;
|
|
2209
|
+
}
|
|
2210
|
+
if (typeof input.stripNulls === "boolean") {
|
|
2211
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
2212
|
+
} else if (rules.stripNullsDefault) {
|
|
2213
|
+
headers["X-Strip-Nulls"] = "true";
|
|
2214
|
+
}
|
|
2215
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
2216
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
2220
|
+
applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
|
|
2221
|
+
}
|
|
2222
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
2223
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
2224
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
2225
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
2226
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
const normalized = normalizeHeaderValue(value);
|
|
2233
|
+
if (normalized) {
|
|
2234
|
+
headers[key] = normalized;
|
|
2235
|
+
}
|
|
2236
|
+
});
|
|
2237
|
+
if (forceNoCache) {
|
|
2238
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
2239
|
+
}
|
|
2240
|
+
return headers;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
// package.json
|
|
2244
|
+
var package_default = {
|
|
2245
|
+
version: "2.12.1"
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
// src/sdk-version.ts
|
|
2249
|
+
var PACKAGE_VERSION = package_default.version;
|
|
2250
|
+
function buildSdkHeaderValue(sdkName) {
|
|
2251
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
// src/gateway/client.ts
|
|
2255
|
+
var DEFAULT_CLIENT = "railway_direct";
|
|
2256
|
+
var SDK_NAME = "xylex-group/athena";
|
|
2257
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
2258
|
+
function parseResponseBody(rawText, contentType) {
|
|
2259
|
+
if (!rawText) {
|
|
2260
|
+
return { parsed: null, parseFailed: false };
|
|
2261
|
+
}
|
|
2262
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
2263
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
2264
|
+
if (!looksJson) {
|
|
2265
|
+
return { parsed: rawText, parseFailed: false };
|
|
2266
|
+
}
|
|
2267
|
+
try {
|
|
2268
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
2269
|
+
} catch {
|
|
2270
|
+
return { parsed: rawText, parseFailed: true };
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2073
2273
|
function isRecord2(value) {
|
|
2074
2274
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2075
2275
|
}
|
|
@@ -2196,71 +2396,10 @@ function buildRpcGetEndpoint(payload) {
|
|
|
2196
2396
|
return withQuery;
|
|
2197
2397
|
}
|
|
2198
2398
|
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
|
-
}
|
|
2399
|
+
return buildServiceRequestHeaders("gateway", SDK_HEADER_VALUE, config, options, {
|
|
2400
|
+
client: options?.client ?? config.client ?? DEFAULT_CLIENT,
|
|
2401
|
+
stripNulls: options?.stripNulls ?? true
|
|
2259
2402
|
});
|
|
2260
|
-
if (forceNoCache) {
|
|
2261
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
2262
|
-
}
|
|
2263
|
-
return headers;
|
|
2264
2403
|
}
|
|
2265
2404
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
2266
2405
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -2917,19 +3056,12 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
|
|
|
2917
3056
|
var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
|
|
2918
3057
|
var SDK_NAME2 = "xylex-group/athena-auth";
|
|
2919
3058
|
var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
|
|
2920
|
-
var NO_CACHE_HEADER_VALUE2 = "no-cache";
|
|
2921
3059
|
function normalizeBaseUrl(baseUrl) {
|
|
2922
3060
|
return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
|
|
2923
3061
|
}
|
|
2924
3062
|
function isRecord4(value) {
|
|
2925
3063
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2926
3064
|
}
|
|
2927
|
-
function normalizeHeaderValue2(value) {
|
|
2928
|
-
return value ? value : void 0;
|
|
2929
|
-
}
|
|
2930
|
-
function isCacheControlHeaderName2(name) {
|
|
2931
|
-
return name.toLowerCase() === "cache-control";
|
|
2932
|
-
}
|
|
2933
3065
|
function parseResponseBody2(rawText, contentType) {
|
|
2934
3066
|
if (!rawText) {
|
|
2935
3067
|
return { parsed: null, parseFailed: false };
|
|
@@ -3129,45 +3261,7 @@ function extractFetchOptions(input) {
|
|
|
3129
3261
|
};
|
|
3130
3262
|
}
|
|
3131
3263
|
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;
|
|
3264
|
+
return buildServiceRequestHeaders("auth", SDK_HEADER_VALUE2, config, options);
|
|
3171
3265
|
}
|
|
3172
3266
|
function appendQueryParam(searchParams, key, value) {
|
|
3173
3267
|
if (value === void 0 || value === null) return;
|
|
@@ -6293,7 +6387,6 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
6293
6387
|
// src/chat/module.ts
|
|
6294
6388
|
var SDK_NAME3 = "xylex-group/athena-chat";
|
|
6295
6389
|
var SDK_HEADER_VALUE3 = buildSdkHeaderValue(SDK_NAME3);
|
|
6296
|
-
var NO_CACHE_HEADER_VALUE3 = "no-cache";
|
|
6297
6390
|
var AthenaChatError = class extends Error {
|
|
6298
6391
|
status;
|
|
6299
6392
|
endpoint;
|
|
@@ -6339,9 +6432,6 @@ function normalizeWsUrl(value, label) {
|
|
|
6339
6432
|
function isRecord7(value) {
|
|
6340
6433
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6341
6434
|
}
|
|
6342
|
-
function normalizeHeaderValue3(value) {
|
|
6343
|
-
return value ? value : void 0;
|
|
6344
|
-
}
|
|
6345
6435
|
function parseResponseBody4(rawText, contentType) {
|
|
6346
6436
|
if (!rawText) {
|
|
6347
6437
|
return { parsed: null, parseFailed: false };
|
|
@@ -6413,39 +6503,7 @@ function createSocket(factory, url, protocols) {
|
|
|
6413
6503
|
}
|
|
6414
6504
|
}
|
|
6415
6505
|
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;
|
|
6506
|
+
return buildServiceRequestHeaders("chat", SDK_HEADER_VALUE3, config, options);
|
|
6449
6507
|
}
|
|
6450
6508
|
function withJsonBody(init, body) {
|
|
6451
6509
|
return {
|
|
@@ -9439,10 +9497,6 @@ function resolveRequiredClientApiKey(value) {
|
|
|
9439
9497
|
}
|
|
9440
9498
|
return normalizedValue;
|
|
9441
9499
|
}
|
|
9442
|
-
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
9443
|
-
const normalizedTargetKey = targetKey.toLowerCase();
|
|
9444
|
-
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
9445
|
-
}
|
|
9446
9500
|
function mergeClientHeaders(current, next) {
|
|
9447
9501
|
if (!current && !next) {
|
|
9448
9502
|
return void 0;
|
|
@@ -9573,6 +9627,9 @@ function resolveCreateClientConfig(config) {
|
|
|
9573
9627
|
userId: config.userId,
|
|
9574
9628
|
organizationId: config.organizationId,
|
|
9575
9629
|
forceNoCache: config.forceNoCache,
|
|
9630
|
+
pgUri: config.pgUri,
|
|
9631
|
+
jdbcUrl: config.jdbcUrl,
|
|
9632
|
+
athenaKey: config.athenaKey,
|
|
9576
9633
|
backend: toBackendConfig(config.backend),
|
|
9577
9634
|
headers: config.headers,
|
|
9578
9635
|
auth: config.auth,
|
|
@@ -9589,18 +9646,6 @@ function createClientFromInput(sourceConfig) {
|
|
|
9589
9646
|
}
|
|
9590
9647
|
function createClientFromConfig(config, sourceConfig) {
|
|
9591
9648
|
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
9649
|
const gateway = createAthenaGatewayClient({
|
|
9605
9650
|
baseUrl: config.baseUrl,
|
|
9606
9651
|
apiKey: config.apiKey,
|
|
@@ -9608,8 +9653,14 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9608
9653
|
userId: config.userId,
|
|
9609
9654
|
organizationId: config.organizationId,
|
|
9610
9655
|
forceNoCache: config.forceNoCache,
|
|
9656
|
+
pgUri: config.pgUri,
|
|
9657
|
+
jdbcUrl: config.jdbcUrl,
|
|
9658
|
+
athenaKey: config.athenaKey,
|
|
9611
9659
|
backend: config.backend,
|
|
9612
|
-
|
|
9660
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9661
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9662
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9663
|
+
headers: config.headers
|
|
9613
9664
|
});
|
|
9614
9665
|
const formatGatewayResult = createResultFormatter(config.experimental);
|
|
9615
9666
|
const queryTracer = createQueryTracer(config.experimental);
|
|
@@ -9667,6 +9718,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9667
9718
|
const chat = createChatModule({
|
|
9668
9719
|
baseUrl: config.chatUrl,
|
|
9669
9720
|
apiKey: config.apiKey,
|
|
9721
|
+
athenaKey: config.athenaKey,
|
|
9670
9722
|
client: config.client,
|
|
9671
9723
|
headers: config.headers,
|
|
9672
9724
|
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
@@ -9703,48 +9755,28 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9703
9755
|
return path.startsWith("/") ? path : `/${path}`;
|
|
9704
9756
|
})();
|
|
9705
9757
|
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
|
-
}
|
|
9758
|
+
const requestProfile = service === "auth" ? "auth" : service === "chat" ? "chat" : service === "storage" ? "storage" : "gateway";
|
|
9759
|
+
const headers = buildAthenaRequestHeaders({
|
|
9760
|
+
profile: requestProfile,
|
|
9761
|
+
sdkHeaderValue: buildSdkHeaderValue(SDK_NAME4),
|
|
9762
|
+
apiKey: options.apiKey ?? (service === "auth" ? normalizedAuthConfig?.apiKey ?? config.apiKey : config.apiKey),
|
|
9763
|
+
athenaKey: options.athenaKey ?? config.athenaKey,
|
|
9764
|
+
client: config.client,
|
|
9765
|
+
userId: config.userId,
|
|
9766
|
+
organizationId: config.organizationId,
|
|
9767
|
+
backend: config.backend,
|
|
9768
|
+
pgUri: config.pgUri,
|
|
9769
|
+
jdbcUrl: config.jdbcUrl,
|
|
9770
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9771
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9772
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9773
|
+
forceNoCache: config.forceNoCache,
|
|
9774
|
+
configHeaders: config.headers,
|
|
9775
|
+
callHeaders: options.headers,
|
|
9776
|
+
accept: service === "chat" ? "application/json" : void 0,
|
|
9777
|
+
contentType: service === "auth" || service === "db" || service === "storage" ? "application/json" : void 0,
|
|
9778
|
+
stripNulls: service === "db" ? true : void 0
|
|
9779
|
+
});
|
|
9748
9780
|
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
9781
|
if (shouldSendJsonBody && !hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
9750
9782
|
headers["Content-Type"] = "application/json";
|