@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RunGeneratorOptions, s as RunGeneratorResult } from './types-
|
|
1
|
+
import { R as RunGeneratorOptions, s as RunGeneratorResult } from './types-DRRb0Fd0.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* End-to-end generator execution: load config, introspect, render, and optionally write files.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RunGeneratorOptions, s as RunGeneratorResult } from './types-
|
|
1
|
+
import { R as RunGeneratorOptions, s as RunGeneratorResult } from './types-BLizCLd1.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* End-to-end generator execution: load config, introspect, render, and optionally write files.
|
package/dist/react.cjs
CHANGED
|
@@ -185,42 +185,31 @@ var getSessionCookie = (request, config) => {
|
|
|
185
185
|
return null;
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
//
|
|
189
|
-
var package_default = {
|
|
190
|
-
version: "2.11.0"
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// src/sdk-version.ts
|
|
194
|
-
var PACKAGE_VERSION = package_default.version;
|
|
195
|
-
function buildSdkHeaderValue(sdkName) {
|
|
196
|
-
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// src/gateway/client.ts
|
|
200
|
-
var DEFAULT_CLIENT = "railway_direct";
|
|
201
|
-
var SDK_NAME = "xylex-group/athena";
|
|
202
|
-
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
188
|
+
// src/utils/athena-request-headers.ts
|
|
203
189
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
190
|
+
var API_KEY_HEADER_CANDIDATES = ["X-Api-Key", "x-api-key", "apikey"];
|
|
191
|
+
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
192
|
+
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
193
|
+
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
194
|
+
var CLIENT_HEADER_CANDIDATES = ["X-Athena-Client", "x-athena-client"];
|
|
195
|
+
var PG_URI_HEADER_CANDIDATES = ["x-pg-uri"];
|
|
196
|
+
var JDBC_URI_HEADER_CANDIDATES = ["x-athena-jdbc-url", "x-jdbc-url"];
|
|
197
|
+
var PROFILE_RULES = {
|
|
198
|
+
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
199
|
+
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
200
|
+
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
201
|
+
auth: { apiKeys: true, routing: false, authMirror: false, authBearer: true, contentType: true },
|
|
202
|
+
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
203
|
+
};
|
|
219
204
|
function normalizeHeaderValue(value) {
|
|
220
205
|
return value ? value : void 0;
|
|
221
206
|
}
|
|
222
|
-
function
|
|
223
|
-
return
|
|
207
|
+
function mergeExtraHeaders(configHeaders, callHeaders) {
|
|
208
|
+
return { ...configHeaders ?? {}, ...callHeaders ?? {} };
|
|
209
|
+
}
|
|
210
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
211
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
212
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
224
213
|
}
|
|
225
214
|
function resolveHeaderValue(headers, candidates) {
|
|
226
215
|
for (const candidate of candidates) {
|
|
@@ -237,13 +226,20 @@ function resolveHeaderValue(headers, candidates) {
|
|
|
237
226
|
}
|
|
238
227
|
return void 0;
|
|
239
228
|
}
|
|
229
|
+
function isCacheControlHeaderName(name) {
|
|
230
|
+
return name.toLowerCase() === "cache-control";
|
|
231
|
+
}
|
|
232
|
+
function normalizeBearerToken(value) {
|
|
233
|
+
const trimmed = value.trim();
|
|
234
|
+
const match = trimmed.match(/^Bearer\s+(.+)$/i);
|
|
235
|
+
return match?.[1]?.trim() ?? trimmed;
|
|
236
|
+
}
|
|
240
237
|
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
241
238
|
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
242
239
|
if (!authorization) {
|
|
243
240
|
return void 0;
|
|
244
241
|
}
|
|
245
|
-
const
|
|
246
|
-
const token = match?.[1]?.trim();
|
|
242
|
+
const token = normalizeBearerToken(authorization);
|
|
247
243
|
return token ? token : void 0;
|
|
248
244
|
}
|
|
249
245
|
function resolveSessionTokenFromCookieHeader(headers) {
|
|
@@ -253,6 +249,210 @@ function resolveSessionTokenFromCookieHeader(headers) {
|
|
|
253
249
|
}
|
|
254
250
|
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
255
251
|
}
|
|
252
|
+
function resolveBackendType(backend) {
|
|
253
|
+
if (!backend) {
|
|
254
|
+
return void 0;
|
|
255
|
+
}
|
|
256
|
+
return typeof backend === "string" ? backend : backend.type;
|
|
257
|
+
}
|
|
258
|
+
function resolveRequestHeaderOverrides(config, options, defaults) {
|
|
259
|
+
return {
|
|
260
|
+
apiKey: options?.apiKey ?? config.apiKey,
|
|
261
|
+
athenaKey: options?.athenaKey ?? config.athenaKey,
|
|
262
|
+
client: options?.client ?? config.client ?? defaults?.client,
|
|
263
|
+
userId: options?.userId ?? config.userId,
|
|
264
|
+
organizationId: options?.organizationId ?? config.organizationId,
|
|
265
|
+
backend: options?.backend ?? config.backend,
|
|
266
|
+
publishEvent: options?.publishEvent ?? config.publishEvent,
|
|
267
|
+
stripNulls: options?.stripNulls ?? config.stripNulls ?? defaults?.stripNulls,
|
|
268
|
+
bearerToken: options?.bearerToken ?? config.bearerToken,
|
|
269
|
+
cookie: options?.cookie ?? config.cookie,
|
|
270
|
+
sessionToken: options?.sessionToken ?? config.sessionToken,
|
|
271
|
+
pgUri: options?.pgUri ?? config.pgUri,
|
|
272
|
+
jdbcUrl: options?.jdbcUrl ?? config.jdbcUrl,
|
|
273
|
+
forceNoCache: Boolean(config.forceNoCache || options?.forceNoCache),
|
|
274
|
+
configHeaders: config.headers,
|
|
275
|
+
callHeaders: options?.headers
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, extras) {
|
|
279
|
+
const rules = PROFILE_RULES[profile];
|
|
280
|
+
return buildAthenaRequestHeaders({
|
|
281
|
+
profile,
|
|
282
|
+
sdkHeaderValue,
|
|
283
|
+
...resolveRequestHeaderOverrides(config, options, {
|
|
284
|
+
client: extras?.client ?? void 0,
|
|
285
|
+
stripNulls: extras?.stripNulls ?? (true )
|
|
286
|
+
}),
|
|
287
|
+
contentType: extras?.contentType ?? ("application/json" ),
|
|
288
|
+
accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
292
|
+
if (apiKey) {
|
|
293
|
+
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
294
|
+
headers.apikey = apiKey;
|
|
295
|
+
}
|
|
296
|
+
if (!Object.hasOwn(headers, "x-api-key")) {
|
|
297
|
+
headers["x-api-key"] = apiKey;
|
|
298
|
+
}
|
|
299
|
+
if (!Object.hasOwn(headers, "X-Api-Key")) {
|
|
300
|
+
headers["X-Api-Key"] = apiKey;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
304
|
+
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
305
|
+
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
309
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
310
|
+
const rules = PROFILE_RULES[input.profile];
|
|
311
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
312
|
+
if (explicitCookie) {
|
|
313
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
314
|
+
}
|
|
315
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
316
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
317
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
318
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
319
|
+
headers.Cookie = explicitCookie;
|
|
320
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
321
|
+
headers.Cookie = cookieFromHeaders;
|
|
322
|
+
}
|
|
323
|
+
const explicitBearerToken = (() => {
|
|
324
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
325
|
+
if (configured) {
|
|
326
|
+
return normalizeBearerToken(configured);
|
|
327
|
+
}
|
|
328
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
329
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
330
|
+
})();
|
|
331
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
332
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
333
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
334
|
+
}
|
|
335
|
+
if (rules.authMirror) {
|
|
336
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
337
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
338
|
+
}
|
|
339
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
340
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
341
|
+
}
|
|
342
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
343
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
347
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
348
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
349
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
350
|
+
headers["x-pg-uri"] = pgUri;
|
|
351
|
+
}
|
|
352
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
353
|
+
if (jdbcUrl) {
|
|
354
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
355
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
356
|
+
}
|
|
357
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
358
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function buildAthenaRequestHeaders(input) {
|
|
363
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
364
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
365
|
+
const rules = PROFILE_RULES[input.profile];
|
|
366
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
367
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
368
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
369
|
+
const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
370
|
+
const headers = {
|
|
371
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
372
|
+
};
|
|
373
|
+
if (rules.contentType) {
|
|
374
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
375
|
+
}
|
|
376
|
+
if (input.accept ?? rules.accept) {
|
|
377
|
+
headers.Accept = input.accept ?? "application/json";
|
|
378
|
+
}
|
|
379
|
+
if (rules.routing) {
|
|
380
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
381
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
382
|
+
}
|
|
383
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
384
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
385
|
+
}
|
|
386
|
+
if (finalClient) {
|
|
387
|
+
headers["X-Athena-Client"] = finalClient;
|
|
388
|
+
}
|
|
389
|
+
const backendType = resolveBackendType(input.backend);
|
|
390
|
+
if (backendType) {
|
|
391
|
+
headers["X-Backend-Type"] = backendType;
|
|
392
|
+
}
|
|
393
|
+
if (typeof input.stripNulls === "boolean") {
|
|
394
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
395
|
+
} else if (rules.stripNullsDefault) {
|
|
396
|
+
headers["X-Strip-Nulls"] = "true";
|
|
397
|
+
}
|
|
398
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
399
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
403
|
+
applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
|
|
404
|
+
}
|
|
405
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
406
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
407
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
408
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
409
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const normalized = normalizeHeaderValue(value);
|
|
416
|
+
if (normalized) {
|
|
417
|
+
headers[key] = normalized;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
if (forceNoCache) {
|
|
421
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
422
|
+
}
|
|
423
|
+
return headers;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// package.json
|
|
427
|
+
var package_default = {
|
|
428
|
+
version: "2.12.1"
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// src/sdk-version.ts
|
|
432
|
+
var PACKAGE_VERSION = package_default.version;
|
|
433
|
+
function buildSdkHeaderValue(sdkName) {
|
|
434
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/gateway/client.ts
|
|
438
|
+
var DEFAULT_CLIENT = "railway_direct";
|
|
439
|
+
var SDK_NAME = "xylex-group/athena";
|
|
440
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
441
|
+
function parseResponseBody(rawText, contentType) {
|
|
442
|
+
if (!rawText) {
|
|
443
|
+
return { parsed: null, parseFailed: false };
|
|
444
|
+
}
|
|
445
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
446
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
447
|
+
if (!looksJson) {
|
|
448
|
+
return { parsed: rawText, parseFailed: false };
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
452
|
+
} catch {
|
|
453
|
+
return { parsed: rawText, parseFailed: true };
|
|
454
|
+
}
|
|
455
|
+
}
|
|
256
456
|
function isRecord(value) {
|
|
257
457
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
258
458
|
}
|
|
@@ -379,71 +579,10 @@ function buildRpcGetEndpoint(payload) {
|
|
|
379
579
|
return withQuery;
|
|
380
580
|
}
|
|
381
581
|
function buildHeaders(config, options) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
...config.headers ?? {},
|
|
386
|
-
...options?.headers ?? {}
|
|
387
|
-
};
|
|
388
|
-
const headerClient = extraHeaders["x-athena-client"] ?? extraHeaders["X-Athena-Client"];
|
|
389
|
-
const finalClient = options?.client ?? config.client ?? (typeof headerClient === "string" ? headerClient : void 0) ?? DEFAULT_CLIENT;
|
|
390
|
-
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
391
|
-
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
392
|
-
const headers = {
|
|
393
|
-
"Content-Type": "application/json",
|
|
394
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE
|
|
395
|
-
};
|
|
396
|
-
if (options?.userId ?? config.userId) {
|
|
397
|
-
headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
|
|
398
|
-
}
|
|
399
|
-
if (options?.organizationId ?? config.organizationId) {
|
|
400
|
-
headers["X-Organization-Id"] = options?.organizationId ?? config.organizationId ?? "";
|
|
401
|
-
}
|
|
402
|
-
if (finalClient) {
|
|
403
|
-
headers["X-Athena-Client"] = finalClient;
|
|
404
|
-
}
|
|
405
|
-
const finalBackend = options?.backend ?? config.backend;
|
|
406
|
-
if (finalBackend) {
|
|
407
|
-
const type = typeof finalBackend === "string" ? finalBackend : finalBackend.type;
|
|
408
|
-
if (type) headers["X-Backend-Type"] = type;
|
|
409
|
-
}
|
|
410
|
-
if (typeof mergedStripNulls === "boolean") {
|
|
411
|
-
headers["X-Strip-Nulls"] = mergedStripNulls ? "true" : "false";
|
|
412
|
-
}
|
|
413
|
-
if (finalPublishEvent) {
|
|
414
|
-
headers["X-Publish-Event"] = finalPublishEvent;
|
|
415
|
-
}
|
|
416
|
-
if (finalApiKey) {
|
|
417
|
-
headers["apikey"] = finalApiKey;
|
|
418
|
-
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
419
|
-
}
|
|
420
|
-
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
421
|
-
"X-Athena-Auth-Session-Token"
|
|
422
|
-
]);
|
|
423
|
-
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
424
|
-
if (derivedSessionToken) {
|
|
425
|
-
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
426
|
-
}
|
|
427
|
-
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
428
|
-
"X-Athena-Auth-Bearer-Token"
|
|
429
|
-
]);
|
|
430
|
-
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
431
|
-
if (derivedBearerToken) {
|
|
432
|
-
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
433
|
-
}
|
|
434
|
-
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
435
|
-
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
436
|
-
if (athenaClientKeys.includes(key)) return;
|
|
437
|
-
if (forceNoCache && isCacheControlHeaderName(key)) return;
|
|
438
|
-
const normalized = normalizeHeaderValue(value);
|
|
439
|
-
if (normalized) {
|
|
440
|
-
headers[key] = normalized;
|
|
441
|
-
}
|
|
582
|
+
return buildServiceRequestHeaders("gateway", SDK_HEADER_VALUE, config, options, {
|
|
583
|
+
client: options?.client ?? config.client ?? DEFAULT_CLIENT,
|
|
584
|
+
stripNulls: options?.stripNulls ?? true
|
|
442
585
|
});
|
|
443
|
-
if (forceNoCache) {
|
|
444
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
445
|
-
}
|
|
446
|
-
return headers;
|
|
447
586
|
}
|
|
448
587
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
449
588
|
const message = error instanceof Error ? error.message : String(error);
|