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