@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/next/client.cjs
CHANGED
|
@@ -160,42 +160,31 @@ var getSessionCookie = (request2, config) => {
|
|
|
160
160
|
return null;
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
//
|
|
164
|
-
var package_default = {
|
|
165
|
-
version: "2.10.0"
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
// src/sdk-version.ts
|
|
169
|
-
var PACKAGE_VERSION = package_default.version;
|
|
170
|
-
function buildSdkHeaderValue(sdkName) {
|
|
171
|
-
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// src/gateway/client.ts
|
|
175
|
-
var DEFAULT_CLIENT = "railway_direct";
|
|
176
|
-
var SDK_NAME = "xylex-group/athena";
|
|
177
|
-
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
163
|
+
// src/utils/athena-request-headers.ts
|
|
178
164
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
165
|
+
var API_KEY_HEADER_CANDIDATES = ["x-api-key", "apikey"];
|
|
166
|
+
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
167
|
+
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
168
|
+
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
169
|
+
var CLIENT_HEADER_CANDIDATES = ["X-Athena-Client", "x-athena-client"];
|
|
170
|
+
var PG_URI_HEADER_CANDIDATES = ["x-pg-uri"];
|
|
171
|
+
var JDBC_URI_HEADER_CANDIDATES = ["x-athena-jdbc-url", "x-jdbc-url"];
|
|
172
|
+
var PROFILE_RULES = {
|
|
173
|
+
gateway: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true, stripNullsDefault: true },
|
|
174
|
+
chat: { apiKeys: true, routing: true, authMirror: true, authBearer: true, accept: true },
|
|
175
|
+
storage: { apiKeys: true, routing: true, authMirror: true, authBearer: false, contentType: true },
|
|
176
|
+
auth: { apiKeys: true, routing: false, authMirror: false, authBearer: true, contentType: true },
|
|
177
|
+
minimal: { apiKeys: false, routing: false, authMirror: false, authBearer: false }
|
|
178
|
+
};
|
|
194
179
|
function normalizeHeaderValue(value) {
|
|
195
180
|
return value ? value : void 0;
|
|
196
181
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
182
|
+
function mergeExtraHeaders(configHeaders, callHeaders) {
|
|
183
|
+
return { ...configHeaders ?? {}, ...callHeaders ?? {} };
|
|
184
|
+
}
|
|
185
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
186
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
187
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
199
188
|
}
|
|
200
189
|
function resolveHeaderValue(headers, candidates) {
|
|
201
190
|
for (const candidate of candidates) {
|
|
@@ -212,13 +201,20 @@ function resolveHeaderValue(headers, candidates) {
|
|
|
212
201
|
}
|
|
213
202
|
return void 0;
|
|
214
203
|
}
|
|
204
|
+
function isCacheControlHeaderName(name) {
|
|
205
|
+
return name.toLowerCase() === "cache-control";
|
|
206
|
+
}
|
|
207
|
+
function normalizeBearerToken(value) {
|
|
208
|
+
const trimmed = value.trim();
|
|
209
|
+
const match = trimmed.match(/^Bearer\s+(.+)$/i);
|
|
210
|
+
return match?.[1]?.trim() ?? trimmed;
|
|
211
|
+
}
|
|
215
212
|
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
216
213
|
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
217
214
|
if (!authorization) {
|
|
218
215
|
return void 0;
|
|
219
216
|
}
|
|
220
|
-
const
|
|
221
|
-
const token = match?.[1]?.trim();
|
|
217
|
+
const token = normalizeBearerToken(authorization);
|
|
222
218
|
return token ? token : void 0;
|
|
223
219
|
}
|
|
224
220
|
function resolveSessionTokenFromCookieHeader(headers) {
|
|
@@ -228,6 +224,207 @@ function resolveSessionTokenFromCookieHeader(headers) {
|
|
|
228
224
|
}
|
|
229
225
|
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
230
226
|
}
|
|
227
|
+
function resolveBackendType(backend) {
|
|
228
|
+
if (!backend) {
|
|
229
|
+
return void 0;
|
|
230
|
+
}
|
|
231
|
+
return typeof backend === "string" ? backend : backend.type;
|
|
232
|
+
}
|
|
233
|
+
function resolveRequestHeaderOverrides(config, options, defaults) {
|
|
234
|
+
return {
|
|
235
|
+
apiKey: options?.apiKey ?? config.apiKey,
|
|
236
|
+
athenaKey: options?.athenaKey ?? config.athenaKey,
|
|
237
|
+
client: options?.client ?? config.client ?? defaults?.client,
|
|
238
|
+
userId: options?.userId ?? config.userId,
|
|
239
|
+
organizationId: options?.organizationId ?? config.organizationId,
|
|
240
|
+
backend: options?.backend ?? config.backend,
|
|
241
|
+
publishEvent: options?.publishEvent ?? config.publishEvent,
|
|
242
|
+
stripNulls: options?.stripNulls ?? config.stripNulls ?? defaults?.stripNulls,
|
|
243
|
+
bearerToken: options?.bearerToken ?? config.bearerToken,
|
|
244
|
+
cookie: options?.cookie ?? config.cookie,
|
|
245
|
+
sessionToken: options?.sessionToken ?? config.sessionToken,
|
|
246
|
+
pgUri: options?.pgUri ?? config.pgUri,
|
|
247
|
+
jdbcUrl: options?.jdbcUrl ?? config.jdbcUrl,
|
|
248
|
+
forceNoCache: Boolean(config.forceNoCache || options?.forceNoCache),
|
|
249
|
+
configHeaders: config.headers,
|
|
250
|
+
callHeaders: options?.headers
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, extras) {
|
|
254
|
+
const rules = PROFILE_RULES[profile];
|
|
255
|
+
return buildAthenaRequestHeaders({
|
|
256
|
+
profile,
|
|
257
|
+
sdkHeaderValue,
|
|
258
|
+
...resolveRequestHeaderOverrides(config, options, {
|
|
259
|
+
client: extras?.client ?? void 0,
|
|
260
|
+
stripNulls: extras?.stripNulls ?? (rules.stripNullsDefault ? true : void 0)
|
|
261
|
+
}),
|
|
262
|
+
contentType: extras?.contentType ?? (rules.contentType ? "application/json" : void 0),
|
|
263
|
+
accept: extras?.accept ?? (rules.accept ? "application/json" : void 0)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
267
|
+
if (apiKey) {
|
|
268
|
+
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
269
|
+
headers.apikey = apiKey;
|
|
270
|
+
}
|
|
271
|
+
if (!hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
272
|
+
headers["x-api-key"] = apiKey;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
276
|
+
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
277
|
+
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function applyAthenaAuthContextHeaders(headers, input) {
|
|
281
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
282
|
+
const rules = PROFILE_RULES[input.profile];
|
|
283
|
+
const explicitCookie = normalizeHeaderValue(input.cookie);
|
|
284
|
+
if (explicitCookie) {
|
|
285
|
+
mergedExtraHeaders.Cookie = explicitCookie;
|
|
286
|
+
}
|
|
287
|
+
const explicitSessionToken = normalizeHeaderValue(input.sessionToken) ?? resolveHeaderValue(mergedExtraHeaders, SESSION_TOKEN_HEADER_CANDIDATES);
|
|
288
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(mergedExtraHeaders);
|
|
289
|
+
const cookieFromHeaders = resolveHeaderValue(mergedExtraHeaders, ["Cookie"]);
|
|
290
|
+
if (explicitCookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
291
|
+
headers.Cookie = explicitCookie;
|
|
292
|
+
} else if (cookieFromHeaders && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
293
|
+
headers.Cookie = cookieFromHeaders;
|
|
294
|
+
}
|
|
295
|
+
const explicitBearerToken = (() => {
|
|
296
|
+
const configured = normalizeHeaderValue(input.bearerToken);
|
|
297
|
+
if (configured) {
|
|
298
|
+
return normalizeBearerToken(configured);
|
|
299
|
+
}
|
|
300
|
+
const mirrored = resolveHeaderValue(mergedExtraHeaders, BEARER_MIRROR_HEADER_CANDIDATES);
|
|
301
|
+
return mirrored ? normalizeBearerToken(mirrored) : void 0;
|
|
302
|
+
})();
|
|
303
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(mergedExtraHeaders);
|
|
304
|
+
if (rules.authBearer && derivedBearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
305
|
+
headers.Authorization = `Bearer ${derivedBearerToken}`;
|
|
306
|
+
}
|
|
307
|
+
if (rules.authMirror) {
|
|
308
|
+
if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
309
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
310
|
+
}
|
|
311
|
+
if (derivedBearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
312
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
313
|
+
}
|
|
314
|
+
} else if (derivedSessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
315
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function applyAthenaPgUriHeaders(headers, input) {
|
|
319
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
320
|
+
const pgUri = normalizeHeaderValue(input.pgUri) ?? resolveHeaderValue(mergedExtraHeaders, PG_URI_HEADER_CANDIDATES);
|
|
321
|
+
if (pgUri && !hasHeaderIgnoreCase(headers, "x-pg-uri")) {
|
|
322
|
+
headers["x-pg-uri"] = pgUri;
|
|
323
|
+
}
|
|
324
|
+
const jdbcUrl = normalizeHeaderValue(input.jdbcUrl) ?? resolveHeaderValue(mergedExtraHeaders, JDBC_URI_HEADER_CANDIDATES);
|
|
325
|
+
if (jdbcUrl) {
|
|
326
|
+
if (!hasHeaderIgnoreCase(headers, "x-athena-jdbc-url")) {
|
|
327
|
+
headers["x-athena-jdbc-url"] = jdbcUrl;
|
|
328
|
+
}
|
|
329
|
+
if (!hasHeaderIgnoreCase(headers, "x-jdbc-url")) {
|
|
330
|
+
headers["x-jdbc-url"] = jdbcUrl;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function buildAthenaRequestHeaders(input) {
|
|
335
|
+
const forceNoCache = Boolean(input.forceNoCache);
|
|
336
|
+
const mergedExtraHeaders = mergeExtraHeaders(input.configHeaders, input.callHeaders);
|
|
337
|
+
const rules = PROFILE_RULES[input.profile];
|
|
338
|
+
const headerClient = resolveHeaderValue(mergedExtraHeaders, CLIENT_HEADER_CANDIDATES);
|
|
339
|
+
const finalClient = normalizeHeaderValue(input.client) ?? headerClient;
|
|
340
|
+
const finalApiKey = normalizeHeaderValue(input.apiKey) ?? resolveHeaderValue(mergedExtraHeaders, API_KEY_HEADER_CANDIDATES);
|
|
341
|
+
const finalAthenaKey = normalizeHeaderValue(input.athenaKey) ?? resolveHeaderValue(mergedExtraHeaders, ATHENA_KEY_HEADER_CANDIDATES) ?? finalApiKey;
|
|
342
|
+
const headers = {
|
|
343
|
+
"X-Athena-Sdk": input.sdkHeaderValue
|
|
344
|
+
};
|
|
345
|
+
if (rules.contentType) {
|
|
346
|
+
headers["Content-Type"] = input.contentType ?? "application/json";
|
|
347
|
+
}
|
|
348
|
+
if (input.accept ?? rules.accept) {
|
|
349
|
+
headers.Accept = input.accept ?? "application/json";
|
|
350
|
+
}
|
|
351
|
+
if (rules.routing) {
|
|
352
|
+
if (normalizeHeaderValue(input.userId)) {
|
|
353
|
+
headers["X-User-Id"] = input.userId ?? "";
|
|
354
|
+
}
|
|
355
|
+
if (normalizeHeaderValue(input.organizationId)) {
|
|
356
|
+
headers["X-Organization-Id"] = input.organizationId ?? "";
|
|
357
|
+
}
|
|
358
|
+
if (finalClient) {
|
|
359
|
+
headers["X-Athena-Client"] = finalClient;
|
|
360
|
+
}
|
|
361
|
+
const backendType = resolveBackendType(input.backend);
|
|
362
|
+
if (backendType) {
|
|
363
|
+
headers["X-Backend-Type"] = backendType;
|
|
364
|
+
}
|
|
365
|
+
if (typeof input.stripNulls === "boolean") {
|
|
366
|
+
headers["X-Strip-Nulls"] = input.stripNulls ? "true" : "false";
|
|
367
|
+
} else if (rules.stripNullsDefault) {
|
|
368
|
+
headers["X-Strip-Nulls"] = "true";
|
|
369
|
+
}
|
|
370
|
+
if (normalizeHeaderValue(input.publishEvent)) {
|
|
371
|
+
headers["X-Publish-Event"] = input.publishEvent ?? "";
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (rules.apiKeys && (finalApiKey || finalAthenaKey)) {
|
|
375
|
+
applyAthenaApiKeyHeaders(headers, finalApiKey, finalAthenaKey);
|
|
376
|
+
}
|
|
377
|
+
applyAthenaAuthContextHeaders(headers, input);
|
|
378
|
+
applyAthenaPgUriHeaders(headers, input);
|
|
379
|
+
const reservedClientHeaderKeys = new Set(CLIENT_HEADER_CANDIDATES.map((key) => key.toLowerCase()));
|
|
380
|
+
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
381
|
+
if (reservedClientHeaderKeys.has(key.toLowerCase())) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (forceNoCache && isCacheControlHeaderName(key)) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const normalized = normalizeHeaderValue(value);
|
|
388
|
+
if (normalized) {
|
|
389
|
+
headers[key] = normalized;
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
if (forceNoCache) {
|
|
393
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
394
|
+
}
|
|
395
|
+
return headers;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// package.json
|
|
399
|
+
var package_default = {
|
|
400
|
+
version: "2.12.0"
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// src/sdk-version.ts
|
|
404
|
+
var PACKAGE_VERSION = package_default.version;
|
|
405
|
+
function buildSdkHeaderValue(sdkName) {
|
|
406
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/gateway/client.ts
|
|
410
|
+
var DEFAULT_CLIENT = "railway_direct";
|
|
411
|
+
var SDK_NAME = "xylex-group/athena";
|
|
412
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
413
|
+
function parseResponseBody(rawText, contentType) {
|
|
414
|
+
if (!rawText) {
|
|
415
|
+
return { parsed: null, parseFailed: false };
|
|
416
|
+
}
|
|
417
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
418
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
419
|
+
if (!looksJson) {
|
|
420
|
+
return { parsed: rawText, parseFailed: false };
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
424
|
+
} catch {
|
|
425
|
+
return { parsed: rawText, parseFailed: true };
|
|
426
|
+
}
|
|
427
|
+
}
|
|
231
428
|
function isRecord(value) {
|
|
232
429
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
233
430
|
}
|
|
@@ -354,71 +551,10 @@ function buildRpcGetEndpoint(payload) {
|
|
|
354
551
|
return withQuery;
|
|
355
552
|
}
|
|
356
553
|
function buildHeaders(config, options) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
...config.headers ?? {},
|
|
361
|
-
...options?.headers ?? {}
|
|
362
|
-
};
|
|
363
|
-
const headerClient = extraHeaders["x-athena-client"] ?? extraHeaders["X-Athena-Client"];
|
|
364
|
-
const finalClient = options?.client ?? config.client ?? (typeof headerClient === "string" ? headerClient : void 0) ?? DEFAULT_CLIENT;
|
|
365
|
-
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
366
|
-
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
367
|
-
const headers = {
|
|
368
|
-
"Content-Type": "application/json",
|
|
369
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE
|
|
370
|
-
};
|
|
371
|
-
if (options?.userId ?? config.userId) {
|
|
372
|
-
headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
|
|
373
|
-
}
|
|
374
|
-
if (options?.organizationId ?? config.organizationId) {
|
|
375
|
-
headers["X-Organization-Id"] = options?.organizationId ?? config.organizationId ?? "";
|
|
376
|
-
}
|
|
377
|
-
if (finalClient) {
|
|
378
|
-
headers["X-Athena-Client"] = finalClient;
|
|
379
|
-
}
|
|
380
|
-
const finalBackend = options?.backend ?? config.backend;
|
|
381
|
-
if (finalBackend) {
|
|
382
|
-
const type = typeof finalBackend === "string" ? finalBackend : finalBackend.type;
|
|
383
|
-
if (type) headers["X-Backend-Type"] = type;
|
|
384
|
-
}
|
|
385
|
-
if (typeof mergedStripNulls === "boolean") {
|
|
386
|
-
headers["X-Strip-Nulls"] = mergedStripNulls ? "true" : "false";
|
|
387
|
-
}
|
|
388
|
-
if (finalPublishEvent) {
|
|
389
|
-
headers["X-Publish-Event"] = finalPublishEvent;
|
|
390
|
-
}
|
|
391
|
-
if (finalApiKey) {
|
|
392
|
-
headers["apikey"] = finalApiKey;
|
|
393
|
-
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
394
|
-
}
|
|
395
|
-
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
396
|
-
"X-Athena-Auth-Session-Token"
|
|
397
|
-
]);
|
|
398
|
-
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
399
|
-
if (derivedSessionToken) {
|
|
400
|
-
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
401
|
-
}
|
|
402
|
-
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
403
|
-
"X-Athena-Auth-Bearer-Token"
|
|
404
|
-
]);
|
|
405
|
-
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
406
|
-
if (derivedBearerToken) {
|
|
407
|
-
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
408
|
-
}
|
|
409
|
-
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
410
|
-
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
411
|
-
if (athenaClientKeys.includes(key)) return;
|
|
412
|
-
if (forceNoCache && isCacheControlHeaderName(key)) return;
|
|
413
|
-
const normalized = normalizeHeaderValue(value);
|
|
414
|
-
if (normalized) {
|
|
415
|
-
headers[key] = normalized;
|
|
416
|
-
}
|
|
554
|
+
return buildServiceRequestHeaders("gateway", SDK_HEADER_VALUE, config, options, {
|
|
555
|
+
client: options?.client ?? config.client ?? DEFAULT_CLIENT,
|
|
556
|
+
stripNulls: options?.stripNulls ?? true
|
|
417
557
|
});
|
|
418
|
-
if (forceNoCache) {
|
|
419
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
420
|
-
}
|
|
421
|
-
return headers;
|
|
422
558
|
}
|
|
423
559
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
424
560
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1075,19 +1211,12 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
|
|
|
1075
1211
|
var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
|
|
1076
1212
|
var SDK_NAME2 = "xylex-group/athena-auth";
|
|
1077
1213
|
var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
|
|
1078
|
-
var NO_CACHE_HEADER_VALUE2 = "no-cache";
|
|
1079
1214
|
function normalizeBaseUrl(baseUrl) {
|
|
1080
1215
|
return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
|
|
1081
1216
|
}
|
|
1082
1217
|
function isRecord3(value) {
|
|
1083
1218
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1084
1219
|
}
|
|
1085
|
-
function normalizeHeaderValue2(value) {
|
|
1086
|
-
return value ? value : void 0;
|
|
1087
|
-
}
|
|
1088
|
-
function isCacheControlHeaderName2(name) {
|
|
1089
|
-
return name.toLowerCase() === "cache-control";
|
|
1090
|
-
}
|
|
1091
1220
|
function parseResponseBody2(rawText, contentType) {
|
|
1092
1221
|
if (!rawText) {
|
|
1093
1222
|
return { parsed: null, parseFailed: false };
|
|
@@ -1152,6 +1281,21 @@ function copyDefinedField(target, source, targetKey, sourceKey) {
|
|
|
1152
1281
|
target[targetKey] = value;
|
|
1153
1282
|
}
|
|
1154
1283
|
}
|
|
1284
|
+
function normalizeEmailTemplateAttachmentsValue(value) {
|
|
1285
|
+
if (typeof value === "string" || value == null) {
|
|
1286
|
+
return value;
|
|
1287
|
+
}
|
|
1288
|
+
if (Array.isArray(value)) {
|
|
1289
|
+
return value.map((item) => normalizeEmailTemplateAttachmentsValue(item));
|
|
1290
|
+
}
|
|
1291
|
+
if (typeof value !== "object") {
|
|
1292
|
+
return value;
|
|
1293
|
+
}
|
|
1294
|
+
const attachment = { ...value };
|
|
1295
|
+
copyDefinedField(attachment, attachment, "file_url", "fileUrl");
|
|
1296
|
+
delete attachment.fileUrl;
|
|
1297
|
+
return attachment;
|
|
1298
|
+
}
|
|
1155
1299
|
function normalizeAdminEmailTemplatePayload(payload) {
|
|
1156
1300
|
const normalized = { ...payload };
|
|
1157
1301
|
copyDefinedField(normalized, payload, "template_key", "templateKey");
|
|
@@ -1162,6 +1306,17 @@ function normalizeAdminEmailTemplatePayload(payload) {
|
|
|
1162
1306
|
copyDefinedField(normalized, payload, "variable_bindings", "variableBindings");
|
|
1163
1307
|
copyDefinedField(normalized, payload, "attachment_failure_mode", "attachmentFailureMode");
|
|
1164
1308
|
copyDefinedField(normalized, payload, "is_active", "isActive");
|
|
1309
|
+
if (Object.hasOwn(payload, "attachments")) {
|
|
1310
|
+
normalized.attachments = normalizeEmailTemplateAttachmentsValue(payload.attachments);
|
|
1311
|
+
}
|
|
1312
|
+
delete normalized.templateKey;
|
|
1313
|
+
delete normalized.eventType;
|
|
1314
|
+
delete normalized.subjectTemplate;
|
|
1315
|
+
delete normalized.textTemplate;
|
|
1316
|
+
delete normalized.htmlTemplate;
|
|
1317
|
+
delete normalized.variableBindings;
|
|
1318
|
+
delete normalized.attachmentFailureMode;
|
|
1319
|
+
delete normalized.isActive;
|
|
1165
1320
|
return normalized;
|
|
1166
1321
|
}
|
|
1167
1322
|
function toReactEmailTemplateCompatibilityInput(input) {
|
|
@@ -1185,6 +1340,17 @@ function normalizeAdminEmailTemplateSendPayload(payload) {
|
|
|
1185
1340
|
copyDefinedField(normalized, payload, "user_id", "userId");
|
|
1186
1341
|
copyDefinedField(normalized, payload, "organization_id", "organizationId");
|
|
1187
1342
|
copyDefinedField(normalized, payload, "session_token", "sessionToken");
|
|
1343
|
+
copyDefinedField(normalized, payload, "attachment_failure_mode", "attachmentFailureMode");
|
|
1344
|
+
if (Object.hasOwn(payload, "attachments")) {
|
|
1345
|
+
normalized.attachments = normalizeEmailTemplateAttachmentsValue(payload.attachments);
|
|
1346
|
+
}
|
|
1347
|
+
delete normalized.templateId;
|
|
1348
|
+
delete normalized.recipientEmail;
|
|
1349
|
+
delete normalized.renderVariables;
|
|
1350
|
+
delete normalized.userId;
|
|
1351
|
+
delete normalized.organizationId;
|
|
1352
|
+
delete normalized.sessionToken;
|
|
1353
|
+
delete normalized.attachmentFailureMode;
|
|
1188
1354
|
return normalized;
|
|
1189
1355
|
}
|
|
1190
1356
|
function toSessionGuardFailure(sessionResult) {
|
|
@@ -1250,45 +1416,7 @@ function extractFetchOptions(input) {
|
|
|
1250
1416
|
};
|
|
1251
1417
|
}
|
|
1252
1418
|
function buildHeaders2(config, options) {
|
|
1253
|
-
|
|
1254
|
-
const headers = {
|
|
1255
|
-
"Content-Type": "application/json",
|
|
1256
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE2
|
|
1257
|
-
};
|
|
1258
|
-
const apiKey = options?.apiKey ?? config.apiKey;
|
|
1259
|
-
if (apiKey) {
|
|
1260
|
-
headers.apikey = apiKey;
|
|
1261
|
-
headers["x-api-key"] = apiKey;
|
|
1262
|
-
}
|
|
1263
|
-
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
1264
|
-
if (bearerToken) {
|
|
1265
|
-
headers.Authorization = `Bearer ${bearerToken}`;
|
|
1266
|
-
}
|
|
1267
|
-
const cookie = options?.cookie ?? config.cookie;
|
|
1268
|
-
if (cookie) {
|
|
1269
|
-
headers.Cookie = cookie;
|
|
1270
|
-
}
|
|
1271
|
-
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
1272
|
-
if (sessionToken) {
|
|
1273
|
-
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
1274
|
-
}
|
|
1275
|
-
const mergedExtraHeaders = {
|
|
1276
|
-
...config.headers ?? {},
|
|
1277
|
-
...options?.headers ?? {}
|
|
1278
|
-
};
|
|
1279
|
-
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
1280
|
-
if (forceNoCache && isCacheControlHeaderName2(key)) {
|
|
1281
|
-
return;
|
|
1282
|
-
}
|
|
1283
|
-
const normalized = normalizeHeaderValue2(value);
|
|
1284
|
-
if (normalized) {
|
|
1285
|
-
headers[key] = normalized;
|
|
1286
|
-
}
|
|
1287
|
-
});
|
|
1288
|
-
if (forceNoCache) {
|
|
1289
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
|
|
1290
|
-
}
|
|
1291
|
-
return headers;
|
|
1419
|
+
return buildServiceRequestHeaders("auth", SDK_HEADER_VALUE2, config, options);
|
|
1292
1420
|
}
|
|
1293
1421
|
function appendQueryParam(searchParams, key, value) {
|
|
1294
1422
|
if (value === void 0 || value === null) return;
|
|
@@ -4750,7 +4878,6 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4750
4878
|
// src/chat/module.ts
|
|
4751
4879
|
var SDK_NAME3 = "xylex-group/athena-chat";
|
|
4752
4880
|
var SDK_HEADER_VALUE3 = buildSdkHeaderValue(SDK_NAME3);
|
|
4753
|
-
var NO_CACHE_HEADER_VALUE3 = "no-cache";
|
|
4754
4881
|
var AthenaChatError = class extends Error {
|
|
4755
4882
|
status;
|
|
4756
4883
|
endpoint;
|
|
@@ -4796,9 +4923,6 @@ function normalizeWsUrl(value, label) {
|
|
|
4796
4923
|
function isRecord7(value) {
|
|
4797
4924
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4798
4925
|
}
|
|
4799
|
-
function normalizeHeaderValue3(value) {
|
|
4800
|
-
return value ? value : void 0;
|
|
4801
|
-
}
|
|
4802
4926
|
function parseResponseBody4(rawText, contentType) {
|
|
4803
4927
|
if (!rawText) {
|
|
4804
4928
|
return { parsed: null, parseFailed: false };
|
|
@@ -4870,39 +4994,7 @@ function createSocket(factory, url, protocols) {
|
|
|
4870
4994
|
}
|
|
4871
4995
|
}
|
|
4872
4996
|
function buildHeaders3(config, options) {
|
|
4873
|
-
|
|
4874
|
-
Accept: "application/json",
|
|
4875
|
-
apikey: config.apiKey,
|
|
4876
|
-
"x-api-key": config.apiKey,
|
|
4877
|
-
"X-Athena-Sdk": SDK_HEADER_VALUE3
|
|
4878
|
-
};
|
|
4879
|
-
if (config.client || options?.client) {
|
|
4880
|
-
headers["X-Athena-Client"] = options?.client ?? config.client ?? "";
|
|
4881
|
-
}
|
|
4882
|
-
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
4883
|
-
if (typeof bearerToken === "string" && bearerToken.trim()) {
|
|
4884
|
-
headers.Authorization = bearerToken.startsWith("Bearer ") ? bearerToken : `Bearer ${bearerToken}`;
|
|
4885
|
-
}
|
|
4886
|
-
const cookie = options?.cookie ?? config.cookie;
|
|
4887
|
-
if (typeof cookie === "string" && cookie.trim()) {
|
|
4888
|
-
headers.Cookie = cookie;
|
|
4889
|
-
}
|
|
4890
|
-
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
4891
|
-
if (typeof sessionToken === "string" && sessionToken.trim()) {
|
|
4892
|
-
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
4893
|
-
}
|
|
4894
|
-
if (config.forceNoCache || options?.forceNoCache) {
|
|
4895
|
-
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE3;
|
|
4896
|
-
}
|
|
4897
|
-
for (const source of [config.headers, options?.headers]) {
|
|
4898
|
-
for (const [key, value] of Object.entries(source ?? {})) {
|
|
4899
|
-
const normalized = normalizeHeaderValue3(value);
|
|
4900
|
-
if (normalized) {
|
|
4901
|
-
headers[key] = normalized;
|
|
4902
|
-
}
|
|
4903
|
-
}
|
|
4904
|
-
}
|
|
4905
|
-
return headers;
|
|
4997
|
+
return buildServiceRequestHeaders("chat", SDK_HEADER_VALUE3, config, options);
|
|
4906
4998
|
}
|
|
4907
4999
|
function withJsonBody(init, body) {
|
|
4908
5000
|
return {
|
|
@@ -5281,6 +5373,9 @@ var AthenaClientBuilderImpl = class {
|
|
|
5281
5373
|
defaultOrganizationId;
|
|
5282
5374
|
forceNoCacheEnabled = false;
|
|
5283
5375
|
defaultHeaders;
|
|
5376
|
+
pgUriValue;
|
|
5377
|
+
jdbcUrlValue;
|
|
5378
|
+
athenaKeyValue;
|
|
5284
5379
|
authConfig;
|
|
5285
5380
|
dbUrlOverride;
|
|
5286
5381
|
gatewayUrlOverride;
|
|
@@ -5307,6 +5402,18 @@ var AthenaClientBuilderImpl = class {
|
|
|
5307
5402
|
this.defaultHeaders = headers;
|
|
5308
5403
|
return this;
|
|
5309
5404
|
}
|
|
5405
|
+
pgUri(pgUri) {
|
|
5406
|
+
this.pgUriValue = pgUri;
|
|
5407
|
+
return this;
|
|
5408
|
+
}
|
|
5409
|
+
jdbcUrl(jdbcUrl) {
|
|
5410
|
+
this.jdbcUrlValue = jdbcUrl;
|
|
5411
|
+
return this;
|
|
5412
|
+
}
|
|
5413
|
+
athenaKey(athenaKey) {
|
|
5414
|
+
this.athenaKeyValue = athenaKey;
|
|
5415
|
+
return this;
|
|
5416
|
+
}
|
|
5310
5417
|
auth(config) {
|
|
5311
5418
|
this.authConfig = mergeAuthClientConfig(this.authConfig, config);
|
|
5312
5419
|
return this;
|
|
@@ -5343,6 +5450,15 @@ var AthenaClientBuilderImpl = class {
|
|
|
5343
5450
|
if (options.headers !== void 0) {
|
|
5344
5451
|
this.defaultHeaders = mergeHeaders(this.defaultHeaders, options.headers);
|
|
5345
5452
|
}
|
|
5453
|
+
if (options.pgUri !== void 0) {
|
|
5454
|
+
this.pgUriValue = options.pgUri;
|
|
5455
|
+
}
|
|
5456
|
+
if (options.jdbcUrl !== void 0) {
|
|
5457
|
+
this.jdbcUrlValue = options.jdbcUrl;
|
|
5458
|
+
}
|
|
5459
|
+
if (options.athenaKey !== void 0) {
|
|
5460
|
+
this.athenaKeyValue = options.athenaKey;
|
|
5461
|
+
}
|
|
5346
5462
|
if (options.auth !== void 0) {
|
|
5347
5463
|
this.authConfig = mergeAuthClientConfig(this.authConfig, options.auth);
|
|
5348
5464
|
}
|
|
@@ -5394,6 +5510,9 @@ var AthenaClientBuilderImpl = class {
|
|
|
5394
5510
|
userId: this.defaultUserId,
|
|
5395
5511
|
organizationId: this.defaultOrganizationId,
|
|
5396
5512
|
forceNoCache: this.forceNoCacheEnabled,
|
|
5513
|
+
pgUri: this.pgUriValue,
|
|
5514
|
+
jdbcUrl: this.jdbcUrlValue,
|
|
5515
|
+
athenaKey: this.athenaKeyValue,
|
|
5397
5516
|
backend: this.backendConfig,
|
|
5398
5517
|
headers: this.defaultHeaders,
|
|
5399
5518
|
db: this.dbUrlOverride ? { url: this.dbUrlOverride } : void 0,
|
|
@@ -8100,10 +8219,6 @@ function resolveRequiredClientApiKey(value) {
|
|
|
8100
8219
|
}
|
|
8101
8220
|
return normalizedValue;
|
|
8102
8221
|
}
|
|
8103
|
-
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
8104
|
-
const normalizedTargetKey = targetKey.toLowerCase();
|
|
8105
|
-
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
8106
|
-
}
|
|
8107
8222
|
function mergeClientHeaders(current, next) {
|
|
8108
8223
|
if (!current && !next) {
|
|
8109
8224
|
return void 0;
|
|
@@ -8234,6 +8349,9 @@ function resolveCreateClientConfig(config) {
|
|
|
8234
8349
|
userId: config.userId,
|
|
8235
8350
|
organizationId: config.organizationId,
|
|
8236
8351
|
forceNoCache: config.forceNoCache,
|
|
8352
|
+
pgUri: config.pgUri,
|
|
8353
|
+
jdbcUrl: config.jdbcUrl,
|
|
8354
|
+
athenaKey: config.athenaKey,
|
|
8237
8355
|
backend: toBackendConfig(config.backend),
|
|
8238
8356
|
headers: config.headers,
|
|
8239
8357
|
auth: config.auth,
|
|
@@ -8250,18 +8368,6 @@ function createClientFromInput(sourceConfig) {
|
|
|
8250
8368
|
}
|
|
8251
8369
|
function createClientFromConfig(config, sourceConfig) {
|
|
8252
8370
|
const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
|
|
8253
|
-
const gatewayHeaders = {
|
|
8254
|
-
...config.headers ?? {}
|
|
8255
|
-
};
|
|
8256
|
-
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
|
|
8257
|
-
gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
|
|
8258
|
-
}
|
|
8259
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
|
|
8260
|
-
gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
|
|
8261
|
-
}
|
|
8262
|
-
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
|
|
8263
|
-
gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
8264
|
-
}
|
|
8265
8371
|
const gateway = createAthenaGatewayClient({
|
|
8266
8372
|
baseUrl: config.baseUrl,
|
|
8267
8373
|
apiKey: config.apiKey,
|
|
@@ -8269,8 +8375,14 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8269
8375
|
userId: config.userId,
|
|
8270
8376
|
organizationId: config.organizationId,
|
|
8271
8377
|
forceNoCache: config.forceNoCache,
|
|
8378
|
+
pgUri: config.pgUri,
|
|
8379
|
+
jdbcUrl: config.jdbcUrl,
|
|
8380
|
+
athenaKey: config.athenaKey,
|
|
8272
8381
|
backend: config.backend,
|
|
8273
|
-
|
|
8382
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
8383
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
8384
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
8385
|
+
headers: config.headers
|
|
8274
8386
|
});
|
|
8275
8387
|
const formatGatewayResult = createResultFormatter(config.experimental);
|
|
8276
8388
|
const queryTracer = createQueryTracer(config.experimental);
|
|
@@ -8328,6 +8440,7 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8328
8440
|
const chat = createChatModule({
|
|
8329
8441
|
baseUrl: config.chatUrl,
|
|
8330
8442
|
apiKey: config.apiKey,
|
|
8443
|
+
athenaKey: config.athenaKey,
|
|
8331
8444
|
client: config.client,
|
|
8332
8445
|
headers: config.headers,
|
|
8333
8446
|
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
@@ -8364,48 +8477,28 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8364
8477
|
return path.startsWith("/") ? path : `/${path}`;
|
|
8365
8478
|
})();
|
|
8366
8479
|
const targetUrl = options.url ? `${normalizedBaseUrl}${toRequestQueryString(options.query)}` : `${normalizedBaseUrl}${normalizedPath}${toRequestQueryString(options.query)}`;
|
|
8367
|
-
const
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
}
|
|
8390
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
8391
|
-
headers.Cookie = normalizedAuthConfig.cookie;
|
|
8392
|
-
}
|
|
8393
|
-
} else {
|
|
8394
|
-
const authApiKey = normalizedAuthConfig?.apiKey ?? config.apiKey;
|
|
8395
|
-
if (authApiKey && !hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
8396
|
-
headers.apikey = headers.apikey ?? authApiKey;
|
|
8397
|
-
headers["x-api-key"] = headers["x-api-key"] ?? authApiKey;
|
|
8398
|
-
}
|
|
8399
|
-
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
8400
|
-
headers.Authorization = `Bearer ${normalizedAuthConfig.bearerToken}`;
|
|
8401
|
-
}
|
|
8402
|
-
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
8403
|
-
headers.Cookie = normalizedAuthConfig.cookie;
|
|
8404
|
-
}
|
|
8405
|
-
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
8406
|
-
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
8407
|
-
}
|
|
8408
|
-
}
|
|
8480
|
+
const requestProfile = service === "auth" ? "auth" : service === "chat" ? "chat" : service === "storage" ? "storage" : "gateway";
|
|
8481
|
+
const headers = buildAthenaRequestHeaders({
|
|
8482
|
+
profile: requestProfile,
|
|
8483
|
+
sdkHeaderValue: buildSdkHeaderValue(SDK_NAME4),
|
|
8484
|
+
apiKey: options.apiKey ?? (service === "auth" ? normalizedAuthConfig?.apiKey ?? config.apiKey : config.apiKey),
|
|
8485
|
+
athenaKey: options.athenaKey ?? config.athenaKey,
|
|
8486
|
+
client: config.client,
|
|
8487
|
+
userId: config.userId,
|
|
8488
|
+
organizationId: config.organizationId,
|
|
8489
|
+
backend: config.backend,
|
|
8490
|
+
pgUri: config.pgUri,
|
|
8491
|
+
jdbcUrl: config.jdbcUrl,
|
|
8492
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
8493
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
8494
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
8495
|
+
forceNoCache: config.forceNoCache,
|
|
8496
|
+
configHeaders: config.headers,
|
|
8497
|
+
callHeaders: options.headers,
|
|
8498
|
+
accept: service === "chat" ? "application/json" : void 0,
|
|
8499
|
+
contentType: service === "auth" || service === "db" || service === "storage" ? "application/json" : void 0,
|
|
8500
|
+
stripNulls: service === "db" ? true : void 0
|
|
8501
|
+
});
|
|
8409
8502
|
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";
|
|
8410
8503
|
if (shouldSendJsonBody && !hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
8411
8504
|
headers["Content-Type"] = "application/json";
|