@xylex-group/athena 2.10.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -28
- package/dist/browser.cjs +333 -240
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +9 -8
- package/dist/browser.d.ts +9 -8
- package/dist/browser.js +333 -240
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +306 -240
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -3
- package/dist/cli/index.d.ts +4 -3
- package/dist/cli/index.js +306 -240
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-BYii6dU9.d.ts → client-C3x75Zgn.d.cts} +22 -9
- package/dist/{client-B7EQ_hPV.d.cts → client-QUbAs7E8.d.ts} +22 -9
- package/dist/index.cjs +333 -240
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +333 -240
- package/dist/index.js.map +1 -1
- package/dist/{model-form-DACdBLYG.d.cts → model-form-CD1uhWSh.d.cts} +2 -1
- package/dist/{model-form-ByvyyvxB.d.ts → model-form-Dm69I-oO.d.ts} +2 -1
- package/dist/{module-DbHlxpeR.d.ts → module-CW3tWJ10.d.ts} +5 -4
- package/dist/{module-DC96HJa3.d.cts → module-Cxcurfes.d.cts} +5 -4
- package/dist/next/client.cjs +333 -240
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +4 -3
- package/dist/next/client.d.ts +4 -3
- package/dist/next/client.js +333 -240
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +333 -240
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +4 -3
- package/dist/next/server.d.ts +4 -3
- package/dist/next/server.js +333 -240
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-CmUZsXsi.d.cts → pipeline-B14jVK7J.d.cts} +1 -1
- package/dist/{pipeline-DZMsPxUg.d.ts → pipeline-BAwb6Vzm.d.ts} +1 -1
- package/dist/react.cjs +234 -98
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -4
- package/dist/react.d.ts +5 -4
- package/dist/react.js +234 -98
- package/dist/react.js.map +1 -1
- package/dist/{shared-DRptGBWP.d.ts → shared-0Kdc74lu.d.ts} +2 -2
- package/dist/{shared-BMVGMnti.d.cts → shared-C0wVICRv.d.cts} +2 -2
- package/dist/{types-C-YvfgYh.d.cts → types-BcVmPBP-.d.ts} +2 -1
- package/dist/types-Cq4-NoB4.d.ts +204 -0
- package/dist/types-CwJCPpLD.d.cts +236 -0
- package/dist/types-CwJCPpLD.d.ts +236 -0
- package/dist/{types-CRjDwmtJ.d.ts → types-DMOoYnPS.d.cts} +2 -1
- package/dist/types-Dr849HD6.d.cts +204 -0
- package/dist/utils.cjs +276 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +58 -1
- package/dist/utils.d.ts +58 -1
- package/dist/utils.js +269 -1
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/dist/types-BeZIHduP.d.cts +0 -428
- package/dist/types-BeZIHduP.d.ts +0 -428
package/dist/react.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { A as AthenaGatewayError, M as ModelFormAdapter, a as ModelFormDefaults, b as ModelFormNullishMode, c as ModelFormValues, T as ToModelFormDefaultsOptions, d as ToModelPayloadOptions, e as createModelFormAdapter, i as isAthenaGatewayError, t as toModelFormDefaults, f as toModelPayload } from './model-form-
|
|
1
|
+
import { q as AthenaGatewayHookConfig, r as AthenaGatewayHookResult } from './types-CwJCPpLD.cjs';
|
|
2
|
+
export { s as AthenaDeletePayload, t as AthenaFetchPayload, a as AthenaGatewayCallOptions, d as AthenaGatewayErrorCode, e as AthenaGatewayErrorDetails, u as AthenaGatewayResponse, v as AthenaInsertPayload, f as AthenaJsonArray, g as AthenaJsonObject, h as AthenaJsonPrimitive, i as AthenaJsonValue, j as AthenaRpcCallOptions, k as AthenaRpcFilter, l as AthenaRpcFilterOperator, m as AthenaRpcOrder, n as AthenaRpcPayload, w as AthenaUpdatePayload } from './types-CwJCPpLD.cjs';
|
|
3
|
+
export { A as AthenaGatewayError, M as ModelFormAdapter, a as ModelFormDefaults, b as ModelFormNullishMode, c as ModelFormValues, T as ToModelFormDefaultsOptions, d as ToModelPayloadOptions, e as createModelFormAdapter, i as isAthenaGatewayError, t as toModelFormDefaults, f as toModelPayload } from './model-form-CD1uhWSh.cjs';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
-
import { f5 as AthenaAuthFetchCompatibleInput, H as AthenaAuthCallOptions, an as AthenaAuthSessionResponse, U as AthenaAuthErrorDetails, ai as AthenaAuthResult, bI as AthenaClientSessionLike, bJ as AthenaClientSessionOptions, c$ as AthenaStorageFileUploadInput, dj as AthenaStorageUploadSource, d5 as AthenaStorageModule, di as AthenaStorageUploadProgressHandler, dh as AthenaStorageUploadProgress, d2 as AthenaStorageFileUploadResult, cL as AthenaStorageCallOptions } from './client-
|
|
6
|
+
import { f5 as AthenaAuthFetchCompatibleInput, H as AthenaAuthCallOptions, an as AthenaAuthSessionResponse, U as AthenaAuthErrorDetails, ai as AthenaAuthResult, bI as AthenaClientSessionLike, bJ as AthenaClientSessionOptions, c$ as AthenaStorageFileUploadInput, dj as AthenaStorageUploadSource, d5 as AthenaStorageModule, di as AthenaStorageUploadProgressHandler, dh as AthenaStorageUploadProgress, d2 as AthenaStorageFileUploadResult, cL as AthenaStorageCallOptions } from './client-C3x75Zgn.cjs';
|
|
7
|
+
import './types-Dr849HD6.cjs';
|
|
7
8
|
|
|
8
9
|
declare function useAthenaGateway(config?: AthenaGatewayHookConfig): AthenaGatewayHookResult;
|
|
9
10
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
export { A as AthenaGatewayError, M as ModelFormAdapter, a as ModelFormDefaults, b as ModelFormNullishMode, c as ModelFormValues, T as ToModelFormDefaultsOptions, d as ToModelPayloadOptions, e as createModelFormAdapter, i as isAthenaGatewayError, t as toModelFormDefaults, f as toModelPayload } from './model-form-
|
|
1
|
+
import { q as AthenaGatewayHookConfig, r as AthenaGatewayHookResult } from './types-CwJCPpLD.js';
|
|
2
|
+
export { s as AthenaDeletePayload, t as AthenaFetchPayload, a as AthenaGatewayCallOptions, d as AthenaGatewayErrorCode, e as AthenaGatewayErrorDetails, u as AthenaGatewayResponse, v as AthenaInsertPayload, f as AthenaJsonArray, g as AthenaJsonObject, h as AthenaJsonPrimitive, i as AthenaJsonValue, j as AthenaRpcCallOptions, k as AthenaRpcFilter, l as AthenaRpcFilterOperator, m as AthenaRpcOrder, n as AthenaRpcPayload, w as AthenaUpdatePayload } from './types-CwJCPpLD.js';
|
|
3
|
+
export { A as AthenaGatewayError, M as ModelFormAdapter, a as ModelFormDefaults, b as ModelFormNullishMode, c as ModelFormValues, T as ToModelFormDefaultsOptions, d as ToModelPayloadOptions, e as createModelFormAdapter, i as isAthenaGatewayError, t as toModelFormDefaults, f as toModelPayload } from './model-form-Dm69I-oO.js';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
-
import { f5 as AthenaAuthFetchCompatibleInput, H as AthenaAuthCallOptions, an as AthenaAuthSessionResponse, U as AthenaAuthErrorDetails, ai as AthenaAuthResult, bI as AthenaClientSessionLike, bJ as AthenaClientSessionOptions, c$ as AthenaStorageFileUploadInput, dj as AthenaStorageUploadSource, d5 as AthenaStorageModule, di as AthenaStorageUploadProgressHandler, dh as AthenaStorageUploadProgress, d2 as AthenaStorageFileUploadResult, cL as AthenaStorageCallOptions } from './client-
|
|
6
|
+
import { f5 as AthenaAuthFetchCompatibleInput, H as AthenaAuthCallOptions, an as AthenaAuthSessionResponse, U as AthenaAuthErrorDetails, ai as AthenaAuthResult, bI as AthenaClientSessionLike, bJ as AthenaClientSessionOptions, c$ as AthenaStorageFileUploadInput, dj as AthenaStorageUploadSource, d5 as AthenaStorageModule, di as AthenaStorageUploadProgressHandler, dh as AthenaStorageUploadProgress, d2 as AthenaStorageFileUploadResult, cL as AthenaStorageCallOptions } from './client-QUbAs7E8.js';
|
|
7
|
+
import './types-Cq4-NoB4.js';
|
|
7
8
|
|
|
8
9
|
declare function useAthenaGateway(config?: AthenaGatewayHookConfig): AthenaGatewayHookResult;
|
|
9
10
|
|
package/dist/react.js
CHANGED
|
@@ -164,42 +164,31 @@ var getSessionCookie = (request, config) => {
|
|
|
164
164
|
return null;
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
//
|
|
168
|
-
var package_default = {
|
|
169
|
-
version: "2.10.0"
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
// src/sdk-version.ts
|
|
173
|
-
var PACKAGE_VERSION = package_default.version;
|
|
174
|
-
function buildSdkHeaderValue(sdkName) {
|
|
175
|
-
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// src/gateway/client.ts
|
|
179
|
-
var DEFAULT_CLIENT = "railway_direct";
|
|
180
|
-
var SDK_NAME = "xylex-group/athena";
|
|
181
|
-
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
167
|
+
// src/utils/athena-request-headers.ts
|
|
182
168
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
169
|
+
var API_KEY_HEADER_CANDIDATES = ["x-api-key", "apikey"];
|
|
170
|
+
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
171
|
+
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
172
|
+
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
173
|
+
var CLIENT_HEADER_CANDIDATES = ["X-Athena-Client", "x-athena-client"];
|
|
174
|
+
var PG_URI_HEADER_CANDIDATES = ["x-pg-uri"];
|
|
175
|
+
var JDBC_URI_HEADER_CANDIDATES = ["x-athena-jdbc-url", "x-jdbc-url"];
|
|
176
|
+
var PROFILE_RULES = {
|
|
177
|
+
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
178
|
+
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
179
|
+
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
180
|
+
auth: { apiKeys: true, routing: false, authMirror: false, authBearer: true, contentType: true },
|
|
181
|
+
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
182
|
+
};
|
|
198
183
|
function normalizeHeaderValue(value) {
|
|
199
184
|
return value ? value : void 0;
|
|
200
185
|
}
|
|
201
|
-
function
|
|
202
|
-
return
|
|
186
|
+
function mergeExtraHeaders(configHeaders, callHeaders) {
|
|
187
|
+
return { ...configHeaders ?? {}, ...callHeaders ?? {} };
|
|
188
|
+
}
|
|
189
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
190
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
191
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
203
192
|
}
|
|
204
193
|
function resolveHeaderValue(headers, candidates) {
|
|
205
194
|
for (const candidate of candidates) {
|
|
@@ -216,13 +205,20 @@ function resolveHeaderValue(headers, candidates) {
|
|
|
216
205
|
}
|
|
217
206
|
return void 0;
|
|
218
207
|
}
|
|
208
|
+
function isCacheControlHeaderName(name) {
|
|
209
|
+
return name.toLowerCase() === "cache-control";
|
|
210
|
+
}
|
|
211
|
+
function normalizeBearerToken(value) {
|
|
212
|
+
const trimmed = value.trim();
|
|
213
|
+
const match = trimmed.match(/^Bearer\s+(.+)$/i);
|
|
214
|
+
return match?.[1]?.trim() ?? trimmed;
|
|
215
|
+
}
|
|
219
216
|
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
220
217
|
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
221
218
|
if (!authorization) {
|
|
222
219
|
return void 0;
|
|
223
220
|
}
|
|
224
|
-
const
|
|
225
|
-
const token = match?.[1]?.trim();
|
|
221
|
+
const token = normalizeBearerToken(authorization);
|
|
226
222
|
return token ? token : void 0;
|
|
227
223
|
}
|
|
228
224
|
function resolveSessionTokenFromCookieHeader(headers) {
|
|
@@ -232,6 +228,207 @@ function resolveSessionTokenFromCookieHeader(headers) {
|
|
|
232
228
|
}
|
|
233
229
|
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
234
230
|
}
|
|
231
|
+
function resolveBackendType(backend) {
|
|
232
|
+
if (!backend) {
|
|
233
|
+
return void 0;
|
|
234
|
+
}
|
|
235
|
+
return typeof backend === "string" ? backend : backend.type;
|
|
236
|
+
}
|
|
237
|
+
function resolveRequestHeaderOverrides(config, options, defaults) {
|
|
238
|
+
return {
|
|
239
|
+
apiKey: options?.apiKey ?? config.apiKey,
|
|
240
|
+
athenaKey: options?.athenaKey ?? config.athenaKey,
|
|
241
|
+
client: options?.client ?? config.client ?? defaults?.client,
|
|
242
|
+
userId: options?.userId ?? config.userId,
|
|
243
|
+
organizationId: options?.organizationId ?? config.organizationId,
|
|
244
|
+
backend: options?.backend ?? config.backend,
|
|
245
|
+
publishEvent: options?.publishEvent ?? config.publishEvent,
|
|
246
|
+
stripNulls: options?.stripNulls ?? config.stripNulls ?? defaults?.stripNulls,
|
|
247
|
+
bearerToken: options?.bearerToken ?? config.bearerToken,
|
|
248
|
+
cookie: options?.cookie ?? config.cookie,
|
|
249
|
+
sessionToken: options?.sessionToken ?? config.sessionToken,
|
|
250
|
+
pgUri: options?.pgUri ?? config.pgUri,
|
|
251
|
+
jdbcUrl: options?.jdbcUrl ?? config.jdbcUrl,
|
|
252
|
+
forceNoCache: Boolean(config.forceNoCache || options?.forceNoCache),
|
|
253
|
+
configHeaders: config.headers,
|
|
254
|
+
callHeaders: options?.headers
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, extras) {
|
|
258
|
+
const rules = PROFILE_RULES[profile];
|
|
259
|
+
return buildAthenaRequestHeaders({
|
|
260
|
+
profile,
|
|
261
|
+
sdkHeaderValue,
|
|
262
|
+
...resolveRequestHeaderOverrides(config, options, {
|
|
263
|
+
client: extras?.client ?? void 0,
|
|
264
|
+
stripNulls: extras?.stripNulls ?? (true )
|
|
265
|
+
}),
|
|
266
|
+
contentType: extras?.contentType ?? ("application/json" ),
|
|
267
|
+
accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
271
|
+
if (apiKey) {
|
|
272
|
+
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
273
|
+
headers.apikey = apiKey;
|
|
274
|
+
}
|
|
275
|
+
if (!hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
276
|
+
headers["x-api-key"] = apiKey;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
280
|
+
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
281
|
+
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
285
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
286
|
+
const rules = PROFILE_RULES[input.profile];
|
|
287
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
288
|
+
if (explicitCookie) {
|
|
289
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
290
|
+
}
|
|
291
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
292
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
293
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
294
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
295
|
+
headers.Cookie = explicitCookie;
|
|
296
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
297
|
+
headers.Cookie = cookieFromHeaders;
|
|
298
|
+
}
|
|
299
|
+
const explicitBearerToken = (() => {
|
|
300
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
301
|
+
if (configured) {
|
|
302
|
+
return normalizeBearerToken(configured);
|
|
303
|
+
}
|
|
304
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
305
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
306
|
+
})();
|
|
307
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
308
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
309
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
310
|
+
}
|
|
311
|
+
if (rules.authMirror) {
|
|
312
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
313
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
314
|
+
}
|
|
315
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
316
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
317
|
+
}
|
|
318
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
319
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
323
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
324
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
325
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
326
|
+
headers["x-pg-uri"] = pgUri;
|
|
327
|
+
}
|
|
328
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
329
|
+
if (jdbcUrl) {
|
|
330
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
331
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
332
|
+
}
|
|
333
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
334
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function buildAthenaRequestHeaders(input) {
|
|
339
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
340
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
341
|
+
const rules = PROFILE_RULES[input.profile];
|
|
342
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
343
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
344
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
345
|
+
const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
346
|
+
const headers = {
|
|
347
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
348
|
+
};
|
|
349
|
+
if (rules.contentType) {
|
|
350
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
351
|
+
}
|
|
352
|
+
if (input.accept ?? rules.accept) {
|
|
353
|
+
headers.Accept = input.accept ?? "application/json";
|
|
354
|
+
}
|
|
355
|
+
if (rules.routing) {
|
|
356
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
357
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
358
|
+
}
|
|
359
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
360
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
361
|
+
}
|
|
362
|
+
if (finalClient) {
|
|
363
|
+
headers["X-Athena-Client"] = finalClient;
|
|
364
|
+
}
|
|
365
|
+
const backendType = resolveBackendType(input.backend);
|
|
366
|
+
if (backendType) {
|
|
367
|
+
headers["X-Backend-Type"] = backendType;
|
|
368
|
+
}
|
|
369
|
+
if (typeof input.stripNulls === "boolean") {
|
|
370
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
371
|
+
} else if (rules.stripNullsDefault) {
|
|
372
|
+
headers["X-Strip-Nulls"] = "true";
|
|
373
|
+
}
|
|
374
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
375
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
379
|
+
applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
|
|
380
|
+
}
|
|
381
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
382
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
383
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
384
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
385
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const normalized = normalizeHeaderValue(value);
|
|
392
|
+
if (normalized) {
|
|
393
|
+
headers[key] = normalized;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
if (forceNoCache) {
|
|
397
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
398
|
+
}
|
|
399
|
+
return headers;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// package.json
|
|
403
|
+
var package_default = {
|
|
404
|
+
version: "2.12.0"
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// src/sdk-version.ts
|
|
408
|
+
var PACKAGE_VERSION = package_default.version;
|
|
409
|
+
function buildSdkHeaderValue(sdkName) {
|
|
410
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// src/gateway/client.ts
|
|
414
|
+
var DEFAULT_CLIENT = "railway_direct";
|
|
415
|
+
var SDK_NAME = "xylex-group/athena";
|
|
416
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
417
|
+
function parseResponseBody(rawText, contentType) {
|
|
418
|
+
if (!rawText) {
|
|
419
|
+
return { parsed: null, parseFailed: false };
|
|
420
|
+
}
|
|
421
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
422
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
423
|
+
if (!looksJson) {
|
|
424
|
+
return { parsed: rawText, parseFailed: false };
|
|
425
|
+
}
|
|
426
|
+
try {
|
|
427
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
428
|
+
} catch {
|
|
429
|
+
return { parsed: rawText, parseFailed: true };
|
|
430
|
+
}
|
|
431
|
+
}
|
|
235
432
|
function isRecord(value) {
|
|
236
433
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
237
434
|
}
|
|
@@ -358,71 +555,10 @@ function buildRpcGetEndpoint(payload) {
|
|
|
358
555
|
return withQuery;
|
|
359
556
|
}
|
|
360
557
|
function buildHeaders(config, options) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
...config.headers ?? {},
|
|
365
|
-
...options?.headers ?? {}
|
|
366
|
-
};
|
|
367
|
-
const headerClient = extraHeaders["x-athena-client"] ?? extraHeaders["X-Athena-Client"];
|
|
368
|
-
const finalClient = options?.client ?? config.client ?? (typeof headerClient === "string" ? headerClient : void 0) ?? DEFAULT_CLIENT;
|
|
369
|
-
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
370
|
-
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
371
|
-
const headers = {
|
|
372
|
-
"Content-Type": "application/json",
|
|
373
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE
|
|
374
|
-
};
|
|
375
|
-
if (options?.userId ?? config.userId) {
|
|
376
|
-
headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
|
|
377
|
-
}
|
|
378
|
-
if (options?.organizationId ?? config.organizationId) {
|
|
379
|
-
headers["X-Organization-Id"] = options?.organizationId ?? config.organizationId ?? "";
|
|
380
|
-
}
|
|
381
|
-
if (finalClient) {
|
|
382
|
-
headers["X-Athena-Client"] = finalClient;
|
|
383
|
-
}
|
|
384
|
-
const finalBackend = options?.backend ?? config.backend;
|
|
385
|
-
if (finalBackend) {
|
|
386
|
-
const type = typeof finalBackend === "string" ? finalBackend : finalBackend.type;
|
|
387
|
-
if (type) headers["X-Backend-Type"] = type;
|
|
388
|
-
}
|
|
389
|
-
if (typeof mergedStripNulls === "boolean") {
|
|
390
|
-
headers["X-Strip-Nulls"] = mergedStripNulls ? "true" : "false";
|
|
391
|
-
}
|
|
392
|
-
if (finalPublishEvent) {
|
|
393
|
-
headers["X-Publish-Event"] = finalPublishEvent;
|
|
394
|
-
}
|
|
395
|
-
if (finalApiKey) {
|
|
396
|
-
headers["apikey"] = finalApiKey;
|
|
397
|
-
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
398
|
-
}
|
|
399
|
-
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
400
|
-
"X-Athena-Auth-Session-Token"
|
|
401
|
-
]);
|
|
402
|
-
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
403
|
-
if (derivedSessionToken) {
|
|
404
|
-
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
405
|
-
}
|
|
406
|
-
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
407
|
-
"X-Athena-Auth-Bearer-Token"
|
|
408
|
-
]);
|
|
409
|
-
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
410
|
-
if (derivedBearerToken) {
|
|
411
|
-
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
412
|
-
}
|
|
413
|
-
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
414
|
-
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
415
|
-
if (athenaClientKeys.includes(key)) return;
|
|
416
|
-
if (forceNoCache && isCacheControlHeaderName(key)) return;
|
|
417
|
-
const normalized = normalizeHeaderValue(value);
|
|
418
|
-
if (normalized) {
|
|
419
|
-
headers[key] = normalized;
|
|
420
|
-
}
|
|
558
|
+
return buildServiceRequestHeaders("gateway", SDK_HEADER_VALUE, config, options, {
|
|
559
|
+
client: options?.client ?? config.client ?? DEFAULT_CLIENT,
|
|
560
|
+
stripNulls: options?.stripNulls ?? true
|
|
421
561
|
});
|
|
422
|
-
if (forceNoCache) {
|
|
423
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
424
|
-
}
|
|
425
|
-
return headers;
|
|
426
562
|
}
|
|
427
563
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
428
564
|
const message = error instanceof Error ? error.message : String(error);
|