@xylex-group/athena 2.1.2 → 2.4.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 +306 -117
- package/dist/browser.cjs +2151 -194
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +14 -14
- package/dist/browser.d.ts +14 -14
- package/dist/browser.js +2146 -194
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +2035 -172
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -3
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +2036 -173
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +2166 -190
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2162 -191
- package/dist/index.js.map +1 -1
- package/dist/{model-form-2hqmoOUX.d.ts → model-form-C0FAbOaf.d.ts} +97 -2
- package/dist/{model-form-Cy-zaO0u.d.cts → model-form-GzTqhEzM.d.cts} +97 -2
- package/dist/{pipeline-BOPszLsL.d.ts → pipeline-CR4V15jF.d.ts} +1 -1
- package/dist/{pipeline-E3FDbs4W.d.cts → pipeline-DZeExYMA.d.cts} +1 -1
- package/dist/{client-BX0NQqOn.d.ts → react-email-BuApZuyG.d.ts} +362 -174
- package/dist/{client-dpAp-NZK.d.cts → react-email-CQJq92zQ.d.cts} +362 -174
- package/dist/react.cjs +279 -21
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +279 -21
- package/dist/react.js.map +1 -1
- package/dist/{types-BaBzjwXr.d.cts → types-09Q4D86N.d.cts} +24 -2
- package/dist/{types-BaBzjwXr.d.ts → types-09Q4D86N.d.ts} +24 -2
- package/dist/{types-CpqL-pZx.d.cts → types-D1JvL21V.d.cts} +1 -1
- package/dist/{types-CeBPrnGj.d.ts → types-DU3gNdFv.d.ts} +1 -1
- package/dist/utils.cjs +153 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +23 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +146 -0
- package/dist/utils.js.map +1 -0
- package/package.json +74 -16
package/dist/react.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
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 { aj as AthenaAuthFetchCompatibleInput, b as AthenaAuthCallOptions, L as AthenaAuthSessionResponse, m as AthenaAuthErrorDetails, H as AthenaAuthResult } from './model-form-GzTqhEzM.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-GzTqhEzM.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 {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
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 { aj as AthenaAuthFetchCompatibleInput, b as AthenaAuthCallOptions, L as AthenaAuthSessionResponse, m as AthenaAuthErrorDetails, H as AthenaAuthResult } from './model-form-C0FAbOaf.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-C0FAbOaf.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
package/dist/react.js
CHANGED
|
@@ -63,8 +63,74 @@ 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
|
+
|
|
66
133
|
// src/gateway/client.ts
|
|
67
|
-
var DEFAULT_BASE_URL = "https://athena-db.com";
|
|
68
134
|
var DEFAULT_CLIENT = "railway_direct";
|
|
69
135
|
var FALLBACK_SDK_VERSION = "1.3.0";
|
|
70
136
|
var SDK_NAME = "xylex-group/athena";
|
|
@@ -91,23 +157,39 @@ function normalizeHeaderValue(value) {
|
|
|
91
157
|
function isRecord(value) {
|
|
92
158
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
93
159
|
}
|
|
160
|
+
function nonEmptyString(value) {
|
|
161
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
162
|
+
}
|
|
163
|
+
function resolveStructuredErrorPayload(payload) {
|
|
164
|
+
if (!isRecord(payload)) return null;
|
|
165
|
+
return isRecord(payload.error) ? payload.error : payload;
|
|
166
|
+
}
|
|
94
167
|
function resolveRequestId(headers) {
|
|
95
168
|
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
96
169
|
}
|
|
97
170
|
function resolveErrorMessage(payload, fallback) {
|
|
98
|
-
|
|
99
|
-
|
|
171
|
+
const structuredPayload = resolveStructuredErrorPayload(payload);
|
|
172
|
+
if (structuredPayload) {
|
|
173
|
+
const messageCandidates = [structuredPayload.message, structuredPayload.error, structuredPayload.details];
|
|
100
174
|
for (const candidate of messageCandidates) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
175
|
+
const resolved = nonEmptyString(candidate);
|
|
176
|
+
if (resolved) return resolved;
|
|
104
177
|
}
|
|
105
178
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
179
|
+
const rawMessage = nonEmptyString(payload);
|
|
180
|
+
if (rawMessage) return rawMessage;
|
|
109
181
|
return fallback;
|
|
110
182
|
}
|
|
183
|
+
function resolveErrorHint(payload) {
|
|
184
|
+
const structuredPayload = resolveStructuredErrorPayload(payload);
|
|
185
|
+
return structuredPayload ? nonEmptyString(structuredPayload.hint) : void 0;
|
|
186
|
+
}
|
|
187
|
+
function resolveStatusText(response, payload) {
|
|
188
|
+
const rawStatusText = nonEmptyString(response.statusText);
|
|
189
|
+
if (rawStatusText) return rawStatusText;
|
|
190
|
+
const payloadRecord = isRecord(payload) ? payload : null;
|
|
191
|
+
return payloadRecord ? nonEmptyString(payloadRecord.statusText) ?? null : null;
|
|
192
|
+
}
|
|
111
193
|
function detailsFromError(error) {
|
|
112
194
|
return error.toDetails();
|
|
113
195
|
}
|
|
@@ -245,9 +327,168 @@ function buildHeaders(config, options) {
|
|
|
245
327
|
});
|
|
246
328
|
return headers;
|
|
247
329
|
}
|
|
330
|
+
function toInvalidUrlResponse(error, endpoint, method) {
|
|
331
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
332
|
+
const gatewayError = error instanceof AthenaGatewayError ? error : new AthenaGatewayError({
|
|
333
|
+
code: "INVALID_URL",
|
|
334
|
+
message,
|
|
335
|
+
status: 0,
|
|
336
|
+
endpoint,
|
|
337
|
+
method,
|
|
338
|
+
cause: message,
|
|
339
|
+
hint: "Set ATHENA_URL to a full http(s) URL before running queries."
|
|
340
|
+
});
|
|
341
|
+
return {
|
|
342
|
+
ok: false,
|
|
343
|
+
status: 0,
|
|
344
|
+
statusText: null,
|
|
345
|
+
data: null,
|
|
346
|
+
error: gatewayError.message,
|
|
347
|
+
errorDetails: detailsFromError(
|
|
348
|
+
new AthenaGatewayError({
|
|
349
|
+
code: gatewayError.code,
|
|
350
|
+
message: gatewayError.message,
|
|
351
|
+
status: gatewayError.status,
|
|
352
|
+
endpoint,
|
|
353
|
+
method,
|
|
354
|
+
requestId: gatewayError.requestId,
|
|
355
|
+
hint: gatewayError.hint,
|
|
356
|
+
cause: gatewayError.causeDetail
|
|
357
|
+
})
|
|
358
|
+
),
|
|
359
|
+
raw: null
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function resolveGatewayBaseUrl(input) {
|
|
363
|
+
return normalizeAthenaGatewayBaseUrl(input, {
|
|
364
|
+
defaultBaseUrl: ATHENA_DEFAULT_BASE_URL
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
function resolveProbePath(path) {
|
|
368
|
+
if (!path) return "/";
|
|
369
|
+
if (!path.startsWith("/")) {
|
|
370
|
+
throw new AthenaGatewayError({
|
|
371
|
+
code: "INVALID_URL",
|
|
372
|
+
message: `Athena gateway probe path must start with "/". Received ${JSON.stringify(path)}.`,
|
|
373
|
+
status: 0,
|
|
374
|
+
hint: 'Use a leading slash such as "/" or "/health".'
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
return path;
|
|
378
|
+
}
|
|
379
|
+
function mergeConnectionHeaders(baseHeaders, headers) {
|
|
380
|
+
const merged = {
|
|
381
|
+
...baseHeaders,
|
|
382
|
+
...headers ?? {}
|
|
383
|
+
};
|
|
384
|
+
if (!merged["X-Athena-Sdk"] && !merged["x-athena-sdk"]) {
|
|
385
|
+
merged["X-Athena-Sdk"] = SDK_HEADER_VALUE;
|
|
386
|
+
}
|
|
387
|
+
return merged;
|
|
388
|
+
}
|
|
389
|
+
async function performConnectionCheck(baseUrl, requestHeaders, options) {
|
|
390
|
+
const path = resolveProbePath(options?.path);
|
|
391
|
+
const url = buildAthenaGatewayUrl(baseUrl, path);
|
|
392
|
+
try {
|
|
393
|
+
const response = await fetch(url, {
|
|
394
|
+
method: "GET",
|
|
395
|
+
headers: mergeConnectionHeaders(requestHeaders, options?.headers),
|
|
396
|
+
signal: options?.signal
|
|
397
|
+
});
|
|
398
|
+
const rawText = await response.text();
|
|
399
|
+
const requestId = resolveRequestId(response.headers);
|
|
400
|
+
const parsedBody = parseResponseBody(
|
|
401
|
+
rawText ?? "",
|
|
402
|
+
response.headers.get("content-type")
|
|
403
|
+
);
|
|
404
|
+
if (parsedBody.parseFailed) {
|
|
405
|
+
const invalidJsonError = new AthenaGatewayError({
|
|
406
|
+
code: "INVALID_JSON",
|
|
407
|
+
message: "Gateway probe returned malformed JSON",
|
|
408
|
+
status: response.status,
|
|
409
|
+
method: "GET",
|
|
410
|
+
requestId,
|
|
411
|
+
hint: "Verify the gateway response body is valid JSON.",
|
|
412
|
+
cause: rawText.slice(0, 300)
|
|
413
|
+
});
|
|
414
|
+
return {
|
|
415
|
+
ok: false,
|
|
416
|
+
reachable: true,
|
|
417
|
+
status: response.status,
|
|
418
|
+
statusText: resolveStatusText(response, parsedBody.parsed),
|
|
419
|
+
baseUrl,
|
|
420
|
+
url,
|
|
421
|
+
error: invalidJsonError.message,
|
|
422
|
+
errorDetails: detailsFromError(invalidJsonError),
|
|
423
|
+
raw: parsedBody.parsed
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const parsed = parsedBody.parsed;
|
|
427
|
+
if (!response.ok) {
|
|
428
|
+
const httpError = new AthenaGatewayError({
|
|
429
|
+
code: "HTTP_ERROR",
|
|
430
|
+
message: resolveErrorMessage(
|
|
431
|
+
parsed,
|
|
432
|
+
`Athena gateway GET ${path} failed with status ${response.status}`
|
|
433
|
+
),
|
|
434
|
+
status: response.status,
|
|
435
|
+
method: "GET",
|
|
436
|
+
requestId,
|
|
437
|
+
hint: resolveErrorHint(parsed)
|
|
438
|
+
});
|
|
439
|
+
return {
|
|
440
|
+
ok: false,
|
|
441
|
+
reachable: true,
|
|
442
|
+
status: response.status,
|
|
443
|
+
statusText: resolveStatusText(response, parsed),
|
|
444
|
+
baseUrl,
|
|
445
|
+
url,
|
|
446
|
+
error: httpError.message,
|
|
447
|
+
errorDetails: detailsFromError(httpError),
|
|
448
|
+
raw: parsed
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
ok: true,
|
|
453
|
+
reachable: true,
|
|
454
|
+
status: response.status,
|
|
455
|
+
statusText: resolveStatusText(response, parsed),
|
|
456
|
+
baseUrl,
|
|
457
|
+
url,
|
|
458
|
+
error: void 0,
|
|
459
|
+
errorDetails: null,
|
|
460
|
+
raw: parsed
|
|
461
|
+
};
|
|
462
|
+
} catch (callError) {
|
|
463
|
+
const message = callError instanceof Error ? callError.message : String(callError);
|
|
464
|
+
const networkError = new AthenaGatewayError({
|
|
465
|
+
code: "NETWORK_ERROR",
|
|
466
|
+
message: `Network error while probing Athena gateway ${url}: ${message}`,
|
|
467
|
+
method: "GET",
|
|
468
|
+
cause: message,
|
|
469
|
+
hint: "Check gateway URL, DNS, and network reachability."
|
|
470
|
+
});
|
|
471
|
+
return {
|
|
472
|
+
ok: false,
|
|
473
|
+
reachable: false,
|
|
474
|
+
status: 0,
|
|
475
|
+
statusText: null,
|
|
476
|
+
baseUrl,
|
|
477
|
+
url,
|
|
478
|
+
error: networkError.message,
|
|
479
|
+
errorDetails: detailsFromError(networkError),
|
|
480
|
+
raw: null
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
}
|
|
248
484
|
async function callAthena(config, endpoint, method, payload, options) {
|
|
249
|
-
|
|
250
|
-
|
|
485
|
+
let baseUrl;
|
|
486
|
+
try {
|
|
487
|
+
baseUrl = resolveGatewayBaseUrl(options?.baseUrl ?? config.baseUrl);
|
|
488
|
+
} catch (error) {
|
|
489
|
+
return toInvalidUrlResponse(error, endpoint, method);
|
|
490
|
+
}
|
|
491
|
+
const url = buildAthenaGatewayUrl(baseUrl, endpoint);
|
|
251
492
|
const headers = buildHeaders(config, options);
|
|
252
493
|
try {
|
|
253
494
|
const requestInit = {
|
|
@@ -278,6 +519,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
278
519
|
return {
|
|
279
520
|
ok: false,
|
|
280
521
|
status: response.status,
|
|
522
|
+
statusText: resolveStatusText(response, parsedBody.parsed),
|
|
281
523
|
data: null,
|
|
282
524
|
error: invalidJsonError.message,
|
|
283
525
|
errorDetails: detailsFromError(invalidJsonError),
|
|
@@ -296,11 +538,13 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
296
538
|
status: response.status,
|
|
297
539
|
endpoint,
|
|
298
540
|
method,
|
|
299
|
-
requestId
|
|
541
|
+
requestId,
|
|
542
|
+
hint: resolveErrorHint(parsed)
|
|
300
543
|
});
|
|
301
544
|
return {
|
|
302
545
|
ok: false,
|
|
303
546
|
status: response.status,
|
|
547
|
+
statusText: resolveStatusText(response, parsed),
|
|
304
548
|
data: null,
|
|
305
549
|
error: httpError.message,
|
|
306
550
|
errorDetails: detailsFromError(httpError),
|
|
@@ -312,6 +556,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
312
556
|
return {
|
|
313
557
|
ok: true,
|
|
314
558
|
status: response.status,
|
|
559
|
+
statusText: resolveStatusText(response, parsed),
|
|
315
560
|
data: payloadData ?? null,
|
|
316
561
|
count: payloadCount,
|
|
317
562
|
error: void 0,
|
|
@@ -331,6 +576,7 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
331
576
|
return {
|
|
332
577
|
ok: false,
|
|
333
578
|
status: 0,
|
|
579
|
+
statusText: null,
|
|
334
580
|
data: null,
|
|
335
581
|
error: networkError.message,
|
|
336
582
|
errorDetails: detailsFromError(networkError),
|
|
@@ -339,32 +585,44 @@ async function callAthena(config, endpoint, method, payload, options) {
|
|
|
339
585
|
}
|
|
340
586
|
}
|
|
341
587
|
function createAthenaGatewayClient(config = {}) {
|
|
588
|
+
const normalizedBaseUrl = resolveGatewayBaseUrl(config.baseUrl);
|
|
589
|
+
const normalizedConfig = {
|
|
590
|
+
...config,
|
|
591
|
+
baseUrl: normalizedBaseUrl
|
|
592
|
+
};
|
|
342
593
|
return {
|
|
343
|
-
baseUrl:
|
|
594
|
+
baseUrl: normalizedBaseUrl,
|
|
344
595
|
buildHeaders(options) {
|
|
345
|
-
return buildHeaders(
|
|
596
|
+
return buildHeaders(normalizedConfig, options);
|
|
597
|
+
},
|
|
598
|
+
verifyConnection(options) {
|
|
599
|
+
return performConnectionCheck(
|
|
600
|
+
normalizedBaseUrl,
|
|
601
|
+
buildHeaders(normalizedConfig),
|
|
602
|
+
options
|
|
603
|
+
);
|
|
346
604
|
},
|
|
347
605
|
fetchGateway(payload, options) {
|
|
348
|
-
return callAthena(
|
|
606
|
+
return callAthena(normalizedConfig, "/gateway/fetch", "POST", payload, options);
|
|
349
607
|
},
|
|
350
608
|
insertGateway(payload, options) {
|
|
351
|
-
return callAthena(
|
|
609
|
+
return callAthena(normalizedConfig, "/gateway/insert", "PUT", payload, options);
|
|
352
610
|
},
|
|
353
611
|
updateGateway(payload, options) {
|
|
354
|
-
return callAthena(
|
|
612
|
+
return callAthena(normalizedConfig, "/gateway/update", "POST", payload, options);
|
|
355
613
|
},
|
|
356
614
|
deleteGateway(payload, options) {
|
|
357
|
-
return callAthena(
|
|
615
|
+
return callAthena(normalizedConfig, "/gateway/delete", "DELETE", payload, options);
|
|
358
616
|
},
|
|
359
617
|
rpcGateway(payload, options) {
|
|
360
618
|
if (options?.get) {
|
|
361
619
|
const endpoint = buildRpcGetEndpoint(payload);
|
|
362
|
-
return callAthena(
|
|
620
|
+
return callAthena(normalizedConfig, endpoint, "GET", null, options);
|
|
363
621
|
}
|
|
364
|
-
return callAthena(
|
|
622
|
+
return callAthena(normalizedConfig, "/gateway/rpc", "POST", payload, options);
|
|
365
623
|
},
|
|
366
624
|
queryGateway(payload, options) {
|
|
367
|
-
return callAthena(
|
|
625
|
+
return callAthena(normalizedConfig, "/gateway/query", "POST", payload, options);
|
|
368
626
|
}
|
|
369
627
|
};
|
|
370
628
|
}
|