@xylex-group/athena 2.3.0 → 2.4.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.
Files changed (42) hide show
  1. package/README.md +195 -106
  2. package/dist/browser.cjs +870 -154
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.cts +7 -7
  5. package/dist/browser.d.ts +7 -7
  6. package/dist/browser.js +869 -155
  7. package/dist/browser.js.map +1 -1
  8. package/dist/cli/index.cjs +905 -144
  9. package/dist/cli/index.cjs.map +1 -1
  10. package/dist/cli/index.d.cts +3 -3
  11. package/dist/cli/index.d.ts +3 -3
  12. package/dist/cli/index.js +905 -144
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/index.cjs +870 -154
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +7 -7
  17. package/dist/index.d.ts +7 -7
  18. package/dist/index.js +869 -155
  19. package/dist/index.js.map +1 -1
  20. package/dist/{model-form-hoE2jHIi.d.cts → model-form-4LPnOPAF.d.cts} +9 -5
  21. package/dist/{model-form-BpDXlbxb.d.ts → model-form-CO4-LmNC.d.ts} +9 -5
  22. package/dist/{pipeline-BNIw8pDQ.d.ts → pipeline-CR4V15jF.d.ts} +1 -1
  23. package/dist/{pipeline-DNIpEsN8.d.cts → pipeline-DZeExYMA.d.cts} +1 -1
  24. package/dist/{react-email-qPA1wjFV.d.ts → react-email-6mOyxBo4.d.cts} +60 -13
  25. package/dist/{react-email-BvyCZnfW.d.cts → react-email-Buhcpglm.d.ts} +60 -13
  26. package/dist/react.cjs +333 -16
  27. package/dist/react.cjs.map +1 -1
  28. package/dist/react.d.cts +4 -4
  29. package/dist/react.d.ts +4 -4
  30. package/dist/react.js +333 -16
  31. package/dist/react.js.map +1 -1
  32. package/dist/{types-A5e97acl.d.cts → types-09Q4D86N.d.cts} +23 -2
  33. package/dist/{types-A5e97acl.d.ts → types-09Q4D86N.d.ts} +23 -2
  34. package/dist/{types-bDlr4u7p.d.cts → types-D1JvL21V.d.cts} +1 -1
  35. package/dist/{types-BnD22-vb.d.ts → types-DU3gNdFv.d.ts} +1 -1
  36. package/dist/utils.cjs +131 -0
  37. package/dist/utils.cjs.map +1 -1
  38. package/dist/utils.d.cts +42 -1
  39. package/dist/utils.d.ts +42 -1
  40. package/dist/utils.js +117 -1
  41. package/dist/utils.js.map +1 -1
  42. package/package.json +40 -40
package/dist/react.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { L as AthenaGatewayHookConfig, N as AthenaGatewayHookResult } from './types-A5e97acl.cjs';
2
- export { O as AthenaDeletePayload, P as AthenaFetchPayload, a as AthenaGatewayCallOptions, b as AthenaGatewayErrorCode, c as AthenaGatewayErrorDetails, Q as AthenaGatewayResponse, V as AthenaInsertPayload, d as AthenaJsonArray, e as AthenaJsonObject, f as AthenaJsonPrimitive, g as AthenaJsonValue, h as AthenaRpcCallOptions, i as AthenaRpcFilter, j as AthenaRpcFilterOperator, k as AthenaRpcOrder, l as AthenaRpcPayload, W as AthenaUpdatePayload } from './types-A5e97acl.cjs';
3
- import { aj as AthenaAuthFetchCompatibleInput, b as AthenaAuthCallOptions, L as AthenaAuthSessionResponse, m as AthenaAuthErrorDetails, H as AthenaAuthResult } from './model-form-hoE2jHIi.cjs';
4
- export { _ as AthenaGatewayError, a9 as ModelFormAdapter, aa as ModelFormDefaults, ab as ModelFormNullishMode, ac as ModelFormValues, ad as ToModelFormDefaultsOptions, ae as ToModelPayloadOptions, af as createModelFormAdapter, ag as isAthenaGatewayError, ah as toModelFormDefaults, ai as toModelPayload } from './model-form-hoE2jHIi.cjs';
1
+ import { O as AthenaGatewayHookConfig, P as AthenaGatewayHookResult } from './types-09Q4D86N.cjs';
2
+ export { Q as AthenaDeletePayload, V as AthenaFetchPayload, a as AthenaGatewayCallOptions, d as AthenaGatewayErrorCode, e as AthenaGatewayErrorDetails, W as AthenaGatewayResponse, X 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, Y as AthenaUpdatePayload } from './types-09Q4D86N.cjs';
3
+ import { ao as AthenaAuthFetchCompatibleInput, e as AthenaAuthCallOptions, Q as AthenaAuthSessionResponse, p as AthenaAuthErrorDetails, L as AthenaAuthResult } from './model-form-4LPnOPAF.cjs';
4
+ export { a3 as AthenaGatewayError, ae as ModelFormAdapter, af as ModelFormDefaults, ag as ModelFormNullishMode, ah as ModelFormValues, ai as ToModelFormDefaultsOptions, aj as ToModelPayloadOptions, ak as createModelFormAdapter, al as isAthenaGatewayError, am as toModelFormDefaults, an as toModelPayload } from './model-form-4LPnOPAF.cjs';
5
5
  import * as react from 'react';
6
6
  import { ReactNode } from 'react';
7
7
 
package/dist/react.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { L as AthenaGatewayHookConfig, N as AthenaGatewayHookResult } from './types-A5e97acl.js';
2
- export { O as AthenaDeletePayload, P as AthenaFetchPayload, a as AthenaGatewayCallOptions, b as AthenaGatewayErrorCode, c as AthenaGatewayErrorDetails, Q as AthenaGatewayResponse, V as AthenaInsertPayload, d as AthenaJsonArray, e as AthenaJsonObject, f as AthenaJsonPrimitive, g as AthenaJsonValue, h as AthenaRpcCallOptions, i as AthenaRpcFilter, j as AthenaRpcFilterOperator, k as AthenaRpcOrder, l as AthenaRpcPayload, W as AthenaUpdatePayload } from './types-A5e97acl.js';
3
- import { aj as AthenaAuthFetchCompatibleInput, b as AthenaAuthCallOptions, L as AthenaAuthSessionResponse, m as AthenaAuthErrorDetails, H as AthenaAuthResult } from './model-form-BpDXlbxb.js';
4
- export { _ as AthenaGatewayError, a9 as ModelFormAdapter, aa as ModelFormDefaults, ab as ModelFormNullishMode, ac as ModelFormValues, ad as ToModelFormDefaultsOptions, ae as ToModelPayloadOptions, af as createModelFormAdapter, ag as isAthenaGatewayError, ah as toModelFormDefaults, ai as toModelPayload } from './model-form-BpDXlbxb.js';
1
+ import { O as AthenaGatewayHookConfig, P as AthenaGatewayHookResult } from './types-09Q4D86N.js';
2
+ export { Q as AthenaDeletePayload, V as AthenaFetchPayload, a as AthenaGatewayCallOptions, d as AthenaGatewayErrorCode, e as AthenaGatewayErrorDetails, W as AthenaGatewayResponse, X 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, Y as AthenaUpdatePayload } from './types-09Q4D86N.js';
3
+ import { ao as AthenaAuthFetchCompatibleInput, e as AthenaAuthCallOptions, Q as AthenaAuthSessionResponse, p as AthenaAuthErrorDetails, L as AthenaAuthResult } from './model-form-CO4-LmNC.js';
4
+ export { a3 as AthenaGatewayError, ae as ModelFormAdapter, af as ModelFormDefaults, ag as ModelFormNullishMode, ah as ModelFormValues, ai as ToModelFormDefaultsOptions, aj as ToModelPayloadOptions, ak as createModelFormAdapter, al as isAthenaGatewayError, am as toModelFormDefaults, an as toModelPayload } from './model-form-CO4-LmNC.js';
5
5
  import * as react from 'react';
6
6
  import { ReactNode } from 'react';
7
7
 
package/dist/react.js CHANGED
@@ -63,13 +63,114 @@ function isAthenaGatewayError(error) {
63
63
  return error instanceof AthenaGatewayError;
64
64
  }
65
65
 
66
+ // src/gateway/url.ts
67
+ var ATHENA_DEFAULT_BASE_URL = "https://athena-db.com";
68
+ function describeReceivedValue(value) {
69
+ if (value === void 0) return "undefined";
70
+ if (value === null) return "null";
71
+ if (typeof value === "string") {
72
+ return value.trim().length > 0 ? JSON.stringify(value) : "an empty string";
73
+ }
74
+ return `${typeof value} ${JSON.stringify(value)}`;
75
+ }
76
+ function invalidBaseUrlError(message, hint) {
77
+ return new AthenaGatewayError({
78
+ code: "INVALID_URL",
79
+ message,
80
+ status: 0,
81
+ hint
82
+ });
83
+ }
84
+ function normalizeAthenaGatewayBaseUrl(input, options = {}) {
85
+ const label = options.label ?? "Athena gateway base URL";
86
+ const candidate = input ?? options.defaultBaseUrl;
87
+ if (candidate === void 0 || candidate === null) {
88
+ throw invalidBaseUrlError(
89
+ `${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(input)}.`,
90
+ 'Set ATHENA_URL (or pass createClient(url, ...)) to a full URL such as "https://mirror3.athena-db.com".'
91
+ );
92
+ }
93
+ const trimmed = candidate.trim();
94
+ if (!trimmed) {
95
+ throw invalidBaseUrlError(
96
+ `${label} must be a non-empty absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
97
+ 'Set ATHENA_URL (or pass createClient(url, ...)) to a full URL such as "https://mirror3.athena-db.com".'
98
+ );
99
+ }
100
+ let parsed;
101
+ try {
102
+ parsed = new URL(trimmed);
103
+ } catch {
104
+ throw invalidBaseUrlError(
105
+ `${label} must be a valid absolute http(s) URL. Received ${describeReceivedValue(candidate)}.`,
106
+ 'Use a full URL including the protocol, for example "https://mirror3.athena-db.com".'
107
+ );
108
+ }
109
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
110
+ throw invalidBaseUrlError(
111
+ `${label} must use http or https. Received ${JSON.stringify(trimmed)}.`,
112
+ 'Use an Athena gateway URL such as "https://mirror3.athena-db.com".'
113
+ );
114
+ }
115
+ if (parsed.search || parsed.hash) {
116
+ throw invalidBaseUrlError(
117
+ `${label} must not include query parameters or hash fragments. Received ${JSON.stringify(trimmed)}.`,
118
+ 'Pass only the base URL. Endpoint paths such as "/gateway/fetch" are appended by the SDK.'
119
+ );
120
+ }
121
+ return parsed.toString().replace(/\/+$/, "");
122
+ }
123
+ function buildAthenaGatewayUrl(baseUrl, path) {
124
+ if (!path.startsWith("/")) {
125
+ throw invalidBaseUrlError(
126
+ `Athena gateway path must start with "/". Received ${JSON.stringify(path)}.`,
127
+ 'Use a leading slash such as "/gateway/fetch" or "/".'
128
+ );
129
+ }
130
+ return `${baseUrl}${path}`;
131
+ }
132
+
133
+ // src/cookies/cookie-utils.ts
134
+ var SECURE_COOKIE_PREFIX = "__Secure-";
135
+ function parseCookies(cookieHeader) {
136
+ const cookies = cookieHeader.split("; ");
137
+ const cookieMap = /* @__PURE__ */ new Map();
138
+ cookies.forEach((cookie) => {
139
+ const [name, value] = cookie.split(/=(.*)/s);
140
+ cookieMap.set(name, value);
141
+ });
142
+ return cookieMap;
143
+ }
144
+ var getSessionCookie = (request, config) => {
145
+ const cookies = (request instanceof Headers || !("headers" in request) ? request : request.headers).get("cookie");
146
+ if (!cookies) {
147
+ return null;
148
+ }
149
+ const { cookieName = "session_token", cookiePrefix = "athena-auth" } = {};
150
+ const parsedCookie = parseCookies(cookies);
151
+ const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
152
+ const sessionToken = getCookie(`${cookiePrefix}.${cookieName}`) || getCookie(`${cookiePrefix}-${cookieName}`);
153
+ if (sessionToken) {
154
+ return sessionToken;
155
+ }
156
+ return null;
157
+ };
158
+
159
+ // package.json
160
+ var package_default = {
161
+ version: "2.4.1"
162
+ };
163
+
164
+ // src/sdk-version.ts
165
+ var PACKAGE_VERSION = package_default.version;
166
+ function buildSdkHeaderValue(sdkName) {
167
+ return `${sdkName} ${PACKAGE_VERSION}`;
168
+ }
169
+
66
170
  // src/gateway/client.ts
67
- var DEFAULT_BASE_URL = "https://athena-db.com";
68
171
  var DEFAULT_CLIENT = "railway_direct";
69
- var FALLBACK_SDK_VERSION = "1.3.0";
70
172
  var SDK_NAME = "xylex-group/athena";
71
- var SDK_VERSION = typeof process !== "undefined" && process?.env?.npm_package_version ? process.env.npm_package_version : FALLBACK_SDK_VERSION;
72
- var SDK_HEADER_VALUE = `${SDK_NAME} ${SDK_VERSION}`;
173
+ var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
73
174
  function parseResponseBody(rawText, contentType) {
74
175
  if (!rawText) {
75
176
  return { parsed: null, parseFailed: false };
@@ -88,6 +189,37 @@ function parseResponseBody(rawText, contentType) {
88
189
  function normalizeHeaderValue(value) {
89
190
  return value ? value : void 0;
90
191
  }
192
+ function resolveHeaderValue(headers, candidates) {
193
+ for (const candidate of candidates) {
194
+ const direct = normalizeHeaderValue(headers[candidate]);
195
+ if (direct) return direct;
196
+ }
197
+ const loweredCandidates = new Set(candidates.map((candidate) => candidate.toLowerCase()));
198
+ for (const [key, value] of Object.entries(headers)) {
199
+ if (!loweredCandidates.has(key.toLowerCase())) {
200
+ continue;
201
+ }
202
+ const normalized = normalizeHeaderValue(value);
203
+ if (normalized) return normalized;
204
+ }
205
+ return void 0;
206
+ }
207
+ function resolveBearerTokenFromAuthorizationHeader(headers) {
208
+ const authorization = resolveHeaderValue(headers, ["Authorization"]);
209
+ if (!authorization) {
210
+ return void 0;
211
+ }
212
+ const match = authorization.match(/^Bearer\s+(.+)$/i);
213
+ const token = match?.[1]?.trim();
214
+ return token ? token : void 0;
215
+ }
216
+ function resolveSessionTokenFromCookieHeader(headers) {
217
+ const cookie = resolveHeaderValue(headers, ["Cookie"]);
218
+ if (!cookie) {
219
+ return void 0;
220
+ }
221
+ return getSessionCookie(new Headers({ cookie })) ?? void 0;
222
+ }
91
223
  function isRecord(value) {
92
224
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
93
225
  }
@@ -205,7 +337,7 @@ function buildRpcGetEndpoint(payload) {
205
337
  status: 0
206
338
  });
207
339
  }
208
- query.set(filter.column, toRpcFilterQueryValue(filter));
340
+ query.append(filter.column, toRpcFilterQueryValue(filter));
209
341
  }
210
342
  }
211
343
  const endpoint = `/rpc/${encodeURIComponent(functionName)}`;
@@ -251,6 +383,20 @@ function buildHeaders(config, options) {
251
383
  headers["apikey"] = finalApiKey;
252
384
  headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
253
385
  }
386
+ const explicitSessionToken = resolveHeaderValue(extraHeaders, [
387
+ "X-Athena-Auth-Session-Token"
388
+ ]);
389
+ const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
390
+ if (derivedSessionToken) {
391
+ headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
392
+ }
393
+ const explicitBearerToken = resolveHeaderValue(extraHeaders, [
394
+ "X-Athena-Auth-Bearer-Token"
395
+ ]);
396
+ const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
397
+ if (derivedBearerToken) {
398
+ headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
399
+ }
254
400
  const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
255
401
  Object.entries(extraHeaders).forEach(([key, value]) => {
256
402
  if (athenaClientKeys.includes(key)) return;
@@ -261,9 +407,168 @@ function buildHeaders(config, options) {
261
407
  });
262
408
  return headers;
263
409
  }
410
+ function toInvalidUrlResponse(error, endpoint, method) {
411
+ const message = error instanceof Error ? error.message : String(error);
412
+ const gatewayError = error instanceof AthenaGatewayError ? error : new AthenaGatewayError({
413
+ code: "INVALID_URL",
414
+ message,
415
+ status: 0,
416
+ endpoint,
417
+ method,
418
+ cause: message,
419
+ hint: "Set ATHENA_URL to a full http(s) URL before running queries."
420
+ });
421
+ return {
422
+ ok: false,
423
+ status: 0,
424
+ statusText: null,
425
+ data: null,
426
+ error: gatewayError.message,
427
+ errorDetails: detailsFromError(
428
+ new AthenaGatewayError({
429
+ code: gatewayError.code,
430
+ message: gatewayError.message,
431
+ status: gatewayError.status,
432
+ endpoint,
433
+ method,
434
+ requestId: gatewayError.requestId,
435
+ hint: gatewayError.hint,
436
+ cause: gatewayError.causeDetail
437
+ })
438
+ ),
439
+ raw: null
440
+ };
441
+ }
442
+ function resolveGatewayBaseUrl(input) {
443
+ return normalizeAthenaGatewayBaseUrl(input, {
444
+ defaultBaseUrl: ATHENA_DEFAULT_BASE_URL
445
+ });
446
+ }
447
+ function resolveProbePath(path) {
448
+ if (!path) return "/";
449
+ if (!path.startsWith("/")) {
450
+ throw new AthenaGatewayError({
451
+ code: "INVALID_URL",
452
+ message: `Athena gateway probe path must start with "/". Received ${JSON.stringify(path)}.`,
453
+ status: 0,
454
+ hint: 'Use a leading slash such as "/" or "/health".'
455
+ });
456
+ }
457
+ return path;
458
+ }
459
+ function mergeConnectionHeaders(baseHeaders, headers) {
460
+ const merged = {
461
+ ...baseHeaders,
462
+ ...headers ?? {}
463
+ };
464
+ if (!merged["X-Athena-Sdk"] && !merged["x-athena-sdk"]) {
465
+ merged["X-Athena-Sdk"] = SDK_HEADER_VALUE;
466
+ }
467
+ return merged;
468
+ }
469
+ async function performConnectionCheck(baseUrl, requestHeaders, options) {
470
+ const path = resolveProbePath(options?.path);
471
+ const url = buildAthenaGatewayUrl(baseUrl, path);
472
+ try {
473
+ const response = await fetch(url, {
474
+ method: "GET",
475
+ headers: mergeConnectionHeaders(requestHeaders, options?.headers),
476
+ signal: options?.signal
477
+ });
478
+ const rawText = await response.text();
479
+ const requestId = resolveRequestId(response.headers);
480
+ const parsedBody = parseResponseBody(
481
+ rawText ?? "",
482
+ response.headers.get("content-type")
483
+ );
484
+ if (parsedBody.parseFailed) {
485
+ const invalidJsonError = new AthenaGatewayError({
486
+ code: "INVALID_JSON",
487
+ message: "Gateway probe returned malformed JSON",
488
+ status: response.status,
489
+ method: "GET",
490
+ requestId,
491
+ hint: "Verify the gateway response body is valid JSON.",
492
+ cause: rawText.slice(0, 300)
493
+ });
494
+ return {
495
+ ok: false,
496
+ reachable: true,
497
+ status: response.status,
498
+ statusText: resolveStatusText(response, parsedBody.parsed),
499
+ baseUrl,
500
+ url,
501
+ error: invalidJsonError.message,
502
+ errorDetails: detailsFromError(invalidJsonError),
503
+ raw: parsedBody.parsed
504
+ };
505
+ }
506
+ const parsed = parsedBody.parsed;
507
+ if (!response.ok) {
508
+ const httpError = new AthenaGatewayError({
509
+ code: "HTTP_ERROR",
510
+ message: resolveErrorMessage(
511
+ parsed,
512
+ `Athena gateway GET ${path} failed with status ${response.status}`
513
+ ),
514
+ status: response.status,
515
+ method: "GET",
516
+ requestId,
517
+ hint: resolveErrorHint(parsed)
518
+ });
519
+ return {
520
+ ok: false,
521
+ reachable: true,
522
+ status: response.status,
523
+ statusText: resolveStatusText(response, parsed),
524
+ baseUrl,
525
+ url,
526
+ error: httpError.message,
527
+ errorDetails: detailsFromError(httpError),
528
+ raw: parsed
529
+ };
530
+ }
531
+ return {
532
+ ok: true,
533
+ reachable: true,
534
+ status: response.status,
535
+ statusText: resolveStatusText(response, parsed),
536
+ baseUrl,
537
+ url,
538
+ error: void 0,
539
+ errorDetails: null,
540
+ raw: parsed
541
+ };
542
+ } catch (callError) {
543
+ const message = callError instanceof Error ? callError.message : String(callError);
544
+ const networkError = new AthenaGatewayError({
545
+ code: "NETWORK_ERROR",
546
+ message: `Network error while probing Athena gateway ${url}: ${message}`,
547
+ method: "GET",
548
+ cause: message,
549
+ hint: "Check gateway URL, DNS, and network reachability."
550
+ });
551
+ return {
552
+ ok: false,
553
+ reachable: false,
554
+ status: 0,
555
+ statusText: null,
556
+ baseUrl,
557
+ url,
558
+ error: networkError.message,
559
+ errorDetails: detailsFromError(networkError),
560
+ raw: null
561
+ };
562
+ }
563
+ }
264
564
  async function callAthena(config, endpoint, method, payload, options) {
265
- const baseUrl = (options?.baseUrl ?? config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
266
- const url = `${baseUrl}${endpoint}`;
565
+ let baseUrl;
566
+ try {
567
+ baseUrl = resolveGatewayBaseUrl(options?.baseUrl ?? config.baseUrl);
568
+ } catch (error) {
569
+ return toInvalidUrlResponse(error, endpoint, method);
570
+ }
571
+ const url = buildAthenaGatewayUrl(baseUrl, endpoint);
267
572
  const headers = buildHeaders(config, options);
268
573
  try {
269
574
  const requestInit = {
@@ -360,32 +665,44 @@ async function callAthena(config, endpoint, method, payload, options) {
360
665
  }
361
666
  }
362
667
  function createAthenaGatewayClient(config = {}) {
668
+ const normalizedBaseUrl = resolveGatewayBaseUrl(config.baseUrl);
669
+ const normalizedConfig = {
670
+ ...config,
671
+ baseUrl: normalizedBaseUrl
672
+ };
363
673
  return {
364
- baseUrl: (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ""),
674
+ baseUrl: normalizedBaseUrl,
365
675
  buildHeaders(options) {
366
- return buildHeaders(config, options);
676
+ return buildHeaders(normalizedConfig, options);
677
+ },
678
+ verifyConnection(options) {
679
+ return performConnectionCheck(
680
+ normalizedBaseUrl,
681
+ buildHeaders(normalizedConfig),
682
+ options
683
+ );
367
684
  },
368
685
  fetchGateway(payload, options) {
369
- return callAthena(config, "/gateway/fetch", "POST", payload, options);
686
+ return callAthena(normalizedConfig, "/gateway/fetch", "POST", payload, options);
370
687
  },
371
688
  insertGateway(payload, options) {
372
- return callAthena(config, "/gateway/insert", "PUT", payload, options);
689
+ return callAthena(normalizedConfig, "/gateway/insert", "PUT", payload, options);
373
690
  },
374
691
  updateGateway(payload, options) {
375
- return callAthena(config, "/gateway/update", "POST", payload, options);
692
+ return callAthena(normalizedConfig, "/gateway/update", "POST", payload, options);
376
693
  },
377
694
  deleteGateway(payload, options) {
378
- return callAthena(config, "/gateway/delete", "DELETE", payload, options);
695
+ return callAthena(normalizedConfig, "/gateway/delete", "DELETE", payload, options);
379
696
  },
380
697
  rpcGateway(payload, options) {
381
698
  if (options?.get) {
382
699
  const endpoint = buildRpcGetEndpoint(payload);
383
- return callAthena(config, endpoint, "GET", null, options);
700
+ return callAthena(normalizedConfig, endpoint, "GET", null, options);
384
701
  }
385
- return callAthena(config, "/gateway/rpc", "POST", payload, options);
702
+ return callAthena(normalizedConfig, "/gateway/rpc", "POST", payload, options);
386
703
  },
387
704
  queryGateway(payload, options) {
388
- return callAthena(config, "/gateway/query", "POST", payload, options);
705
+ return callAthena(normalizedConfig, "/gateway/query", "POST", payload, options);
389
706
  }
390
707
  };
391
708
  }