@xylex-group/athena 1.9.0 → 2.0.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/dist/cli/index.js CHANGED
@@ -290,6 +290,76 @@ function resolvePostgresColumnType(column) {
290
290
  return wrapArrayType(baseType, column.arrayDimensions);
291
291
  }
292
292
 
293
+ // src/gateway/errors.ts
294
+ var AthenaGatewayError = class _AthenaGatewayError extends Error {
295
+ code;
296
+ status;
297
+ endpoint;
298
+ method;
299
+ requestId;
300
+ hint;
301
+ causeDetail;
302
+ constructor(input) {
303
+ super(input.message);
304
+ this.name = "AthenaGatewayError";
305
+ this.code = input.code;
306
+ this.status = input.status ?? 0;
307
+ this.endpoint = input.endpoint;
308
+ this.method = input.method;
309
+ this.requestId = input.requestId;
310
+ this.hint = input.hint;
311
+ this.causeDetail = input.cause;
312
+ }
313
+ toDetails() {
314
+ return {
315
+ code: this.code,
316
+ message: this.message,
317
+ status: this.status,
318
+ endpoint: this.endpoint,
319
+ method: this.method,
320
+ requestId: this.requestId,
321
+ hint: this.hint,
322
+ cause: this.causeDetail
323
+ };
324
+ }
325
+ static fromResponse(response, fallback) {
326
+ const details = response.errorDetails;
327
+ if (details) {
328
+ return new _AthenaGatewayError({
329
+ code: details.code,
330
+ message: details.message,
331
+ status: details.status,
332
+ endpoint: details.endpoint ?? fallback.endpoint,
333
+ method: details.method ?? fallback.method,
334
+ requestId: details.requestId ?? fallback.requestId,
335
+ hint: details.hint,
336
+ cause: details.cause
337
+ });
338
+ }
339
+ return new _AthenaGatewayError({
340
+ code: "HTTP_ERROR",
341
+ message: response.error ?? "Gateway request failed",
342
+ status: response.status,
343
+ endpoint: fallback.endpoint,
344
+ method: fallback.method,
345
+ requestId: fallback.requestId
346
+ });
347
+ }
348
+ };
349
+
350
+ // src/auxiliaries.ts
351
+ function parseBooleanFlag(rawValue, fallback) {
352
+ if (!rawValue) return fallback;
353
+ const normalized = rawValue.trim().toLowerCase();
354
+ if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
355
+ return true;
356
+ }
357
+ if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
358
+ return false;
359
+ }
360
+ return fallback;
361
+ }
362
+
293
363
  // src/generator/schema-selection.ts
294
364
  var DEFAULT_POSTGRES_SCHEMAS = ["public"];
295
365
  function collectSchemaNames(input) {
@@ -349,6 +419,39 @@ var DEFAULT_EXPERIMENTAL_FLAGS = {
349
419
  postgresGatewayIntrospection: false,
350
420
  scyllaProviderContracts: true
351
421
  };
422
+ function normalizeBooleanFlag(rawValue, fallback) {
423
+ if (typeof rawValue === "boolean") {
424
+ return rawValue;
425
+ }
426
+ if (typeof rawValue === "string") {
427
+ return parseBooleanFlag(rawValue, fallback);
428
+ }
429
+ return fallback;
430
+ }
431
+ function normalizeFeatureFlags(input) {
432
+ return {
433
+ emitRelations: normalizeBooleanFlag(
434
+ input?.emitRelations,
435
+ DEFAULT_FEATURES.emitRelations
436
+ ),
437
+ emitRegistry: normalizeBooleanFlag(
438
+ input?.emitRegistry,
439
+ DEFAULT_FEATURES.emitRegistry
440
+ )
441
+ };
442
+ }
443
+ function normalizeExperimentalFlags(input) {
444
+ return {
445
+ postgresGatewayIntrospection: normalizeBooleanFlag(
446
+ input?.postgresGatewayIntrospection,
447
+ DEFAULT_EXPERIMENTAL_FLAGS.postgresGatewayIntrospection
448
+ ),
449
+ scyllaProviderContracts: normalizeBooleanFlag(
450
+ input?.scyllaProviderContracts,
451
+ DEFAULT_EXPERIMENTAL_FLAGS.scyllaProviderContracts
452
+ )
453
+ };
454
+ }
352
455
  function normalizeOutputConfig(output) {
353
456
  return {
354
457
  targets: {
@@ -384,14 +487,8 @@ function normalizeGeneratorConfig(input) {
384
487
  ...DEFAULT_NAMING,
385
488
  ...input.naming ?? {}
386
489
  },
387
- features: {
388
- ...DEFAULT_FEATURES,
389
- ...input.features ?? {}
390
- },
391
- experimental: {
392
- ...DEFAULT_EXPERIMENTAL_FLAGS,
393
- ...input.experimental ?? {}
394
- }
490
+ features: normalizeFeatureFlags(input.features),
491
+ experimental: normalizeExperimentalFlags(input.experimental)
395
492
  };
396
493
  }
397
494
  function findGeneratorConfigPath(cwd = process.cwd()) {
@@ -720,63 +817,6 @@ function generateArtifactsFromSnapshot(snapshot, config) {
720
817
  return new ArtifactComposer(snapshot, normalizedConfig).compose();
721
818
  }
722
819
 
723
- // src/gateway/errors.ts
724
- var AthenaGatewayError = class _AthenaGatewayError extends Error {
725
- code;
726
- status;
727
- endpoint;
728
- method;
729
- requestId;
730
- hint;
731
- causeDetail;
732
- constructor(input) {
733
- super(input.message);
734
- this.name = "AthenaGatewayError";
735
- this.code = input.code;
736
- this.status = input.status ?? 0;
737
- this.endpoint = input.endpoint;
738
- this.method = input.method;
739
- this.requestId = input.requestId;
740
- this.hint = input.hint;
741
- this.causeDetail = input.cause;
742
- }
743
- toDetails() {
744
- return {
745
- code: this.code,
746
- message: this.message,
747
- status: this.status,
748
- endpoint: this.endpoint,
749
- method: this.method,
750
- requestId: this.requestId,
751
- hint: this.hint,
752
- cause: this.causeDetail
753
- };
754
- }
755
- static fromResponse(response, fallback) {
756
- const details = response.errorDetails;
757
- if (details) {
758
- return new _AthenaGatewayError({
759
- code: details.code,
760
- message: details.message,
761
- status: details.status,
762
- endpoint: details.endpoint ?? fallback.endpoint,
763
- method: details.method ?? fallback.method,
764
- requestId: details.requestId ?? fallback.requestId,
765
- hint: details.hint,
766
- cause: details.cause
767
- });
768
- }
769
- return new _AthenaGatewayError({
770
- code: "HTTP_ERROR",
771
- message: response.error ?? "Gateway request failed",
772
- status: response.status,
773
- endpoint: fallback.endpoint,
774
- method: fallback.method,
775
- requestId: fallback.requestId
776
- });
777
- }
778
- };
779
-
780
820
  // src/gateway/client.ts
781
821
  var DEFAULT_BASE_URL = "https://athena-db.com";
782
822
  var DEFAULT_CLIENT = "railway_direct";
@@ -1198,6 +1238,1044 @@ function quoteSelectColumnsExpression(columns) {
1198
1238
  return tokens.map(quoteSelectToken).join(", ");
1199
1239
  }
1200
1240
 
1241
+ // src/auth/client.ts
1242
+ var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
1243
+ var FALLBACK_SDK_VERSION2 = "1.0.0";
1244
+ var SDK_NAME2 = "xylex-group/athena-auth";
1245
+ var SDK_VERSION2 = typeof process !== "undefined" && process?.env?.npm_package_version ? process.env.npm_package_version : FALLBACK_SDK_VERSION2;
1246
+ var SDK_HEADER_VALUE2 = `${SDK_NAME2} ${SDK_VERSION2}`;
1247
+ function normalizeBaseUrl(baseUrl) {
1248
+ return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
1249
+ }
1250
+ function isRecord2(value) {
1251
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1252
+ }
1253
+ function normalizeHeaderValue2(value) {
1254
+ return value ? value : void 0;
1255
+ }
1256
+ function parseResponseBody2(rawText, contentType) {
1257
+ if (!rawText) {
1258
+ return { parsed: null, parseFailed: false };
1259
+ }
1260
+ const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
1261
+ const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
1262
+ if (!looksJson) {
1263
+ return { parsed: rawText, parseFailed: false };
1264
+ }
1265
+ try {
1266
+ return { parsed: JSON.parse(rawText), parseFailed: false };
1267
+ } catch {
1268
+ return { parsed: rawText, parseFailed: true };
1269
+ }
1270
+ }
1271
+ function resolveRequestId2(headers) {
1272
+ return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
1273
+ }
1274
+ function resolveErrorMessage2(payload, fallback) {
1275
+ if (isRecord2(payload)) {
1276
+ const messageCandidates = [payload.error, payload.message, payload.details];
1277
+ for (const candidate of messageCandidates) {
1278
+ if (typeof candidate === "string" && candidate.trim().length > 0) {
1279
+ return candidate.trim();
1280
+ }
1281
+ }
1282
+ }
1283
+ if (typeof payload === "string" && payload.trim().length > 0) {
1284
+ return payload.trim();
1285
+ }
1286
+ return fallback;
1287
+ }
1288
+ function toErrorDetails(input) {
1289
+ return {
1290
+ code: input.code,
1291
+ message: input.message,
1292
+ status: input.status,
1293
+ endpoint: input.endpoint,
1294
+ method: input.method,
1295
+ requestId: input.requestId,
1296
+ hint: input.hint,
1297
+ cause: input.cause
1298
+ };
1299
+ }
1300
+ function mergeCallOptions(base, override) {
1301
+ if (!base && !override) return void 0;
1302
+ return {
1303
+ ...base,
1304
+ ...override,
1305
+ headers: {
1306
+ ...base?.headers ?? {},
1307
+ ...override?.headers ?? {}
1308
+ }
1309
+ };
1310
+ }
1311
+ function extractFetchOptions(input) {
1312
+ if (!input) {
1313
+ return {
1314
+ payload: void 0,
1315
+ fetchOptions: void 0
1316
+ };
1317
+ }
1318
+ const { fetchOptions, ...rest } = input;
1319
+ const hasPayloadKeys = Object.keys(rest).length > 0;
1320
+ return {
1321
+ payload: hasPayloadKeys ? rest : void 0,
1322
+ fetchOptions
1323
+ };
1324
+ }
1325
+ function buildHeaders2(config, options) {
1326
+ const headers = {
1327
+ "Content-Type": "application/json",
1328
+ "X-Athena-Sdk": SDK_HEADER_VALUE2
1329
+ };
1330
+ const apiKey = options?.apiKey ?? config.apiKey;
1331
+ if (apiKey) {
1332
+ headers.apikey = apiKey;
1333
+ headers["x-api-key"] = apiKey;
1334
+ }
1335
+ const bearerToken = options?.bearerToken ?? config.bearerToken;
1336
+ if (bearerToken) {
1337
+ headers.Authorization = `Bearer ${bearerToken}`;
1338
+ }
1339
+ const mergedExtraHeaders = {
1340
+ ...config.headers ?? {},
1341
+ ...options?.headers ?? {}
1342
+ };
1343
+ Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
1344
+ const normalized = normalizeHeaderValue2(value);
1345
+ if (normalized) {
1346
+ headers[key] = normalized;
1347
+ }
1348
+ });
1349
+ return headers;
1350
+ }
1351
+ function appendQueryParam(searchParams, key, value) {
1352
+ if (value === void 0 || value === null) return;
1353
+ if (Array.isArray(value)) {
1354
+ value.forEach((item) => {
1355
+ searchParams.append(key, String(item));
1356
+ });
1357
+ return;
1358
+ }
1359
+ searchParams.append(key, String(value));
1360
+ }
1361
+ function buildRequestUrl(baseUrl, endpoint, query) {
1362
+ const url = `${baseUrl}${endpoint}`;
1363
+ if (!query || Object.keys(query).length === 0) return url;
1364
+ const searchParams = new URLSearchParams();
1365
+ Object.entries(query).forEach(([key, value]) => appendQueryParam(searchParams, key, value));
1366
+ const queryText = searchParams.toString();
1367
+ return queryText ? `${url}?${queryText}` : url;
1368
+ }
1369
+ function inferDefaultMethod(endpoint) {
1370
+ if (endpoint.startsWith("/reset-password/")) {
1371
+ return "GET";
1372
+ }
1373
+ switch (endpoint) {
1374
+ case "/get-session":
1375
+ case "/list-sessions":
1376
+ case "/verify-email":
1377
+ case "/change-email/verify":
1378
+ case "/delete-user/verify":
1379
+ case "/email-list":
1380
+ case "/email/list":
1381
+ case "/delete-user/callback":
1382
+ case "/list-accounts":
1383
+ case "/passkey/generate-register-options":
1384
+ case "/passkey/list-user-passkeys":
1385
+ case "/.well-known/webauthn":
1386
+ case "/admin/list-users":
1387
+ case "/admin/athena-client/list":
1388
+ case "/admin/audit-log/list":
1389
+ case "/admin/email/get":
1390
+ case "/admin/email-failure/list":
1391
+ case "/admin/email-failure/get":
1392
+ case "/admin/email-template/get":
1393
+ case "/admin/email-template/list":
1394
+ case "/admin/email/list":
1395
+ case "/api-key/get":
1396
+ case "/api-key/list":
1397
+ case "/organization/get-full-organization":
1398
+ case "/organization/list":
1399
+ case "/organization/get-invitation":
1400
+ case "/organization/list-invitations":
1401
+ case "/organization/list-user-invitations":
1402
+ case "/organization/list-members":
1403
+ case "/organization/get-active-member":
1404
+ case "/health":
1405
+ case "/ok":
1406
+ case "/error":
1407
+ return "GET";
1408
+ default:
1409
+ return "POST";
1410
+ }
1411
+ }
1412
+ async function callAuthEndpoint(config, context, body, query, options) {
1413
+ const baseUrl = normalizeBaseUrl(options?.baseUrl ?? config.baseUrl);
1414
+ const url = buildRequestUrl(baseUrl, context.endpoint, query);
1415
+ const headers = buildHeaders2(config, options);
1416
+ const credentials = options?.credentials ?? config.credentials ?? "include";
1417
+ const requestInit = {
1418
+ method: context.method,
1419
+ headers,
1420
+ credentials,
1421
+ signal: options?.signal
1422
+ };
1423
+ if (context.method !== "GET") {
1424
+ requestInit.body = JSON.stringify(body ?? {});
1425
+ }
1426
+ const fetcher = config.fetch ?? globalThis.fetch;
1427
+ if (!fetcher) {
1428
+ const details = toErrorDetails({
1429
+ code: "UNKNOWN_ERROR",
1430
+ message: "No fetch implementation available for auth client",
1431
+ status: 0,
1432
+ endpoint: context.endpoint,
1433
+ method: context.method,
1434
+ hint: "Use Node 18+ or provide `fetch` via createClient(..., { auth: { fetch } }) or createAuthClient({ fetch })"
1435
+ });
1436
+ return {
1437
+ ok: false,
1438
+ status: 0,
1439
+ data: null,
1440
+ error: details.message,
1441
+ errorDetails: details,
1442
+ raw: null
1443
+ };
1444
+ }
1445
+ try {
1446
+ const response = await fetcher(url, requestInit);
1447
+ const rawText = await response.text();
1448
+ const requestId = resolveRequestId2(response.headers);
1449
+ const parsedBody = parseResponseBody2(rawText ?? "", response.headers.get("content-type"));
1450
+ if (parsedBody.parseFailed) {
1451
+ const details = toErrorDetails({
1452
+ code: "INVALID_JSON",
1453
+ message: "Auth server returned malformed JSON",
1454
+ status: response.status,
1455
+ endpoint: context.endpoint,
1456
+ method: context.method,
1457
+ requestId,
1458
+ hint: "Verify the auth endpoint response body is valid JSON.",
1459
+ cause: rawText.slice(0, 300)
1460
+ });
1461
+ return {
1462
+ ok: false,
1463
+ status: response.status,
1464
+ data: null,
1465
+ error: details.message,
1466
+ errorDetails: details,
1467
+ raw: parsedBody.parsed
1468
+ };
1469
+ }
1470
+ const parsed = parsedBody.parsed;
1471
+ if (!response.ok) {
1472
+ const details = toErrorDetails({
1473
+ code: "HTTP_ERROR",
1474
+ message: resolveErrorMessage2(
1475
+ parsed,
1476
+ `Auth endpoint ${context.method} ${context.endpoint} failed with status ${response.status}`
1477
+ ),
1478
+ status: response.status,
1479
+ endpoint: context.endpoint,
1480
+ method: context.method,
1481
+ requestId
1482
+ });
1483
+ return {
1484
+ ok: false,
1485
+ status: response.status,
1486
+ data: null,
1487
+ error: details.message,
1488
+ errorDetails: details,
1489
+ raw: parsed
1490
+ };
1491
+ }
1492
+ return {
1493
+ ok: true,
1494
+ status: response.status,
1495
+ data: parsed ?? null,
1496
+ error: null,
1497
+ errorDetails: null,
1498
+ raw: parsed
1499
+ };
1500
+ } catch (callError) {
1501
+ const message = callError instanceof Error ? callError.message : String(callError);
1502
+ const details = toErrorDetails({
1503
+ code: "NETWORK_ERROR",
1504
+ message: `Network error while calling ${context.method} ${context.endpoint}: ${message}`,
1505
+ status: 0,
1506
+ endpoint: context.endpoint,
1507
+ method: context.method,
1508
+ cause: message,
1509
+ hint: "Check auth server URL, DNS, and network reachability."
1510
+ });
1511
+ return {
1512
+ ok: false,
1513
+ status: 0,
1514
+ data: null,
1515
+ error: details.message,
1516
+ errorDetails: details,
1517
+ raw: null
1518
+ };
1519
+ }
1520
+ }
1521
+ function executePostWithCompatibleInput(config, context, input, options) {
1522
+ const { payload, fetchOptions } = extractFetchOptions(input);
1523
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1524
+ return callAuthEndpoint(config, context, payload ?? {}, void 0, mergedOptions);
1525
+ }
1526
+ function executePostWithOptionalInput(config, context, input, options) {
1527
+ const { fetchOptions } = extractFetchOptions(input);
1528
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1529
+ return callAuthEndpoint(config, context, {}, void 0, mergedOptions);
1530
+ }
1531
+ function executeGetWithCompatibleInput(config, context, input, options) {
1532
+ const { fetchOptions } = extractFetchOptions(input);
1533
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1534
+ return callAuthEndpoint(config, context, void 0, void 0, mergedOptions);
1535
+ }
1536
+ function executeGetWithQueryCompatibleInput(config, context, input, options) {
1537
+ const { payload, fetchOptions } = extractFetchOptions(input);
1538
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1539
+ const query = payload?.query;
1540
+ return callAuthEndpoint(
1541
+ config,
1542
+ context,
1543
+ void 0,
1544
+ query,
1545
+ mergedOptions
1546
+ );
1547
+ }
1548
+ function createAuthClient(config = {}) {
1549
+ const normalizedBaseUrl = normalizeBaseUrl(config.baseUrl);
1550
+ const resolvedConfig = {
1551
+ ...config,
1552
+ baseUrl: normalizedBaseUrl
1553
+ };
1554
+ const request = (input, options) => {
1555
+ const method = input.method ?? (input.body !== void 0 ? "POST" : inferDefaultMethod(input.endpoint));
1556
+ const mergedOptions = mergeCallOptions(input.fetchOptions, options);
1557
+ return callAuthEndpoint(
1558
+ resolvedConfig,
1559
+ { endpoint: input.endpoint, method },
1560
+ input.body,
1561
+ input.query,
1562
+ mergedOptions
1563
+ );
1564
+ };
1565
+ const postGeneric = (endpoint, input, options) => {
1566
+ const { payload, fetchOptions } = extractFetchOptions(input);
1567
+ return request(
1568
+ {
1569
+ endpoint,
1570
+ method: "POST",
1571
+ body: payload ?? {},
1572
+ fetchOptions
1573
+ },
1574
+ options
1575
+ );
1576
+ };
1577
+ const getGeneric = (endpoint, input, options) => {
1578
+ const { fetchOptions } = extractFetchOptions(input);
1579
+ return request(
1580
+ {
1581
+ endpoint,
1582
+ method: "GET",
1583
+ fetchOptions
1584
+ },
1585
+ options
1586
+ );
1587
+ };
1588
+ const getWithQuery = (endpoint, input, options) => {
1589
+ const { payload, fetchOptions } = extractFetchOptions(input);
1590
+ const query = payload?.query;
1591
+ return request(
1592
+ {
1593
+ endpoint,
1594
+ method: "GET",
1595
+ query,
1596
+ fetchOptions
1597
+ },
1598
+ options
1599
+ );
1600
+ };
1601
+ const listUserEmailsWithFallback = async (input, options) => {
1602
+ const primary = await getWithQuery(
1603
+ "/email/list",
1604
+ input,
1605
+ options
1606
+ );
1607
+ if (primary.ok || primary.status !== 404 || primary.errorDetails?.code !== "HTTP_ERROR") {
1608
+ return primary;
1609
+ }
1610
+ return getWithQuery(
1611
+ "/email-list",
1612
+ input,
1613
+ options
1614
+ );
1615
+ };
1616
+ const healthWithFallback = async (input, options) => {
1617
+ const primary = await getGeneric("/health", input, options);
1618
+ if (primary.ok || primary.status !== 404 || primary.errorDetails?.code !== "HTTP_ERROR") {
1619
+ return primary;
1620
+ }
1621
+ const fallback = await getGeneric("/ok", input, options);
1622
+ if (!fallback.ok) {
1623
+ return {
1624
+ ...fallback,
1625
+ data: null
1626
+ };
1627
+ }
1628
+ const fallbackStatus = isRecord2(fallback.data) && typeof fallback.data.ok === "boolean" ? fallback.data.ok ? "ok" : "error" : "ok";
1629
+ return {
1630
+ ...fallback,
1631
+ data: {
1632
+ status: fallbackStatus
1633
+ }
1634
+ };
1635
+ };
1636
+ const signOut = (input, options) => executePostWithOptionalInput(
1637
+ resolvedConfig,
1638
+ { endpoint: "/sign-out", method: "POST" },
1639
+ input,
1640
+ options
1641
+ );
1642
+ const revokeSessions = (input, options) => executePostWithOptionalInput(
1643
+ resolvedConfig,
1644
+ { endpoint: "/revoke-sessions", method: "POST" },
1645
+ input,
1646
+ options
1647
+ );
1648
+ const revokeOtherSessions = (input, options) => executePostWithOptionalInput(
1649
+ resolvedConfig,
1650
+ { endpoint: "/revoke-other-sessions", method: "POST" },
1651
+ input,
1652
+ options
1653
+ );
1654
+ const revokeSession = (input, options) => executePostWithCompatibleInput(
1655
+ resolvedConfig,
1656
+ { endpoint: "/revoke-session", method: "POST" },
1657
+ input,
1658
+ options
1659
+ );
1660
+ const deleteUser = (input, options) => {
1661
+ const { payload, fetchOptions } = extractFetchOptions(input);
1662
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1663
+ return callAuthEndpoint(
1664
+ resolvedConfig,
1665
+ { endpoint: "/delete-user", method: "POST" },
1666
+ payload ?? {},
1667
+ void 0,
1668
+ mergedOptions
1669
+ );
1670
+ };
1671
+ const deleteUserCallback = (input, options) => {
1672
+ const { payload, fetchOptions } = extractFetchOptions(input);
1673
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1674
+ const query = payload ?? {};
1675
+ return callAuthEndpoint(
1676
+ resolvedConfig,
1677
+ { endpoint: "/delete-user/callback", method: "GET" },
1678
+ void 0,
1679
+ {
1680
+ token: query.token,
1681
+ callbackURL: query.callbackURL
1682
+ },
1683
+ mergedOptions
1684
+ );
1685
+ };
1686
+ const resolveResetPasswordToken = (input, options) => {
1687
+ const { payload, fetchOptions } = extractFetchOptions(input);
1688
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
1689
+ const query = payload;
1690
+ const token = query?.token?.trim();
1691
+ if (!token) {
1692
+ throw new Error("resolveResetPasswordToken requires a non-empty token");
1693
+ }
1694
+ const endpoint = `/reset-password/${encodeURIComponent(token)}`;
1695
+ return callAuthEndpoint(
1696
+ resolvedConfig,
1697
+ { endpoint, method: "GET" },
1698
+ void 0,
1699
+ query?.callbackURL ? { callbackURL: query.callbackURL } : void 0,
1700
+ mergedOptions
1701
+ );
1702
+ };
1703
+ const organization = {
1704
+ create: (input, options) => executePostWithCompatibleInput(
1705
+ resolvedConfig,
1706
+ { endpoint: "/organization/create", method: "POST" },
1707
+ input,
1708
+ options
1709
+ ),
1710
+ update: (input, options) => executePostWithCompatibleInput(
1711
+ resolvedConfig,
1712
+ { endpoint: "/organization/update", method: "POST" },
1713
+ input,
1714
+ options
1715
+ ),
1716
+ delete: (input, options) => executePostWithCompatibleInput(
1717
+ resolvedConfig,
1718
+ { endpoint: "/organization/delete", method: "POST" },
1719
+ input,
1720
+ options
1721
+ ),
1722
+ setActive: (input, options) => executePostWithCompatibleInput(
1723
+ resolvedConfig,
1724
+ { endpoint: "/organization/set-active", method: "POST" },
1725
+ input,
1726
+ options
1727
+ ),
1728
+ list: (input, options) => getGeneric(
1729
+ "/organization/list",
1730
+ input,
1731
+ options
1732
+ ),
1733
+ getFull: (input, options) => executeGetWithQueryCompatibleInput(
1734
+ resolvedConfig,
1735
+ { endpoint: "/organization/get-full-organization", method: "GET" },
1736
+ input,
1737
+ options
1738
+ ),
1739
+ checkSlug: (input, options) => executePostWithCompatibleInput(
1740
+ resolvedConfig,
1741
+ { endpoint: "/organization/check-slug", method: "POST" },
1742
+ input,
1743
+ options
1744
+ ),
1745
+ leave: (input, options) => executePostWithCompatibleInput(
1746
+ resolvedConfig,
1747
+ { endpoint: "/organization/leave", method: "POST" },
1748
+ input,
1749
+ options
1750
+ ),
1751
+ listUserInvitations: (input, options) => executeGetWithQueryCompatibleInput(
1752
+ resolvedConfig,
1753
+ { endpoint: "/organization/list-user-invitations", method: "GET" },
1754
+ input,
1755
+ options
1756
+ ),
1757
+ hasPermission: (input, options) => postGeneric(
1758
+ "/organization/has-permission",
1759
+ input,
1760
+ options
1761
+ ),
1762
+ invitation: {
1763
+ cancel: (input, options) => executePostWithCompatibleInput(
1764
+ resolvedConfig,
1765
+ { endpoint: "/organization/cancel-invitation", method: "POST" },
1766
+ input,
1767
+ options
1768
+ ),
1769
+ accept: (input, options) => executePostWithCompatibleInput(
1770
+ resolvedConfig,
1771
+ { endpoint: "/organization/accept-invitation", method: "POST" },
1772
+ input,
1773
+ options
1774
+ ),
1775
+ get: (input, options) => executeGetWithQueryCompatibleInput(
1776
+ resolvedConfig,
1777
+ { endpoint: "/organization/get-invitation", method: "GET" },
1778
+ input,
1779
+ options
1780
+ ),
1781
+ reject: (input, options) => executePostWithCompatibleInput(
1782
+ resolvedConfig,
1783
+ { endpoint: "/organization/reject-invitation", method: "POST" },
1784
+ input,
1785
+ options
1786
+ ),
1787
+ list: (input, options) => executeGetWithQueryCompatibleInput(
1788
+ resolvedConfig,
1789
+ { endpoint: "/organization/list-invitations", method: "GET" },
1790
+ input,
1791
+ options
1792
+ )
1793
+ },
1794
+ member: {
1795
+ remove: (input, options) => executePostWithCompatibleInput(
1796
+ resolvedConfig,
1797
+ { endpoint: "/organization/remove-member", method: "POST" },
1798
+ input,
1799
+ options
1800
+ ),
1801
+ updateRole: (input, options) => executePostWithCompatibleInput(
1802
+ resolvedConfig,
1803
+ { endpoint: "/organization/update-member-role", method: "POST" },
1804
+ input,
1805
+ options
1806
+ ),
1807
+ invite: (input, options) => executePostWithCompatibleInput(
1808
+ resolvedConfig,
1809
+ { endpoint: "/organization/invite-member", method: "POST" },
1810
+ input,
1811
+ options
1812
+ ),
1813
+ getActive: (input, options) => executeGetWithCompatibleInput(
1814
+ resolvedConfig,
1815
+ { endpoint: "/organization/get-active-member", method: "GET" },
1816
+ input,
1817
+ options
1818
+ ),
1819
+ list: (input, options) => executeGetWithQueryCompatibleInput(
1820
+ resolvedConfig,
1821
+ { endpoint: "/organization/list-members", method: "GET" },
1822
+ input,
1823
+ options
1824
+ )
1825
+ }
1826
+ };
1827
+ const authResetPassword = Object.assign(
1828
+ (input, options) => executePostWithCompatibleInput(
1829
+ resolvedConfig,
1830
+ { endpoint: "/reset-password", method: "POST" },
1831
+ input,
1832
+ options
1833
+ ),
1834
+ {
1835
+ token: resolveResetPasswordToken
1836
+ }
1837
+ );
1838
+ const sessionRevokeBinding = (input, options) => {
1839
+ if (Array.isArray(input)) {
1840
+ if (input.length === 0) {
1841
+ throw new Error("session.revoke requires at least one session token");
1842
+ }
1843
+ if (input.length === 1) {
1844
+ return revokeSession(input[0], options);
1845
+ }
1846
+ return revokeSessions(void 0, options);
1847
+ }
1848
+ const parsed = input;
1849
+ const tokens = Array.isArray(parsed.tokens) ? parsed.tokens.filter((token2) => token2.trim().length > 0) : void 0;
1850
+ if (tokens && tokens.length > 1) {
1851
+ return revokeSessions(
1852
+ parsed.fetchOptions ? { fetchOptions: parsed.fetchOptions } : void 0,
1853
+ options
1854
+ );
1855
+ }
1856
+ if (tokens && tokens.length === 1) {
1857
+ return revokeSession(
1858
+ { token: tokens[0], fetchOptions: parsed.fetchOptions },
1859
+ options
1860
+ );
1861
+ }
1862
+ const token = parsed.token?.trim();
1863
+ if (!token) {
1864
+ throw new Error("session.revoke requires a non-empty token or a non-empty token list");
1865
+ }
1866
+ return revokeSession(
1867
+ {
1868
+ token,
1869
+ fetchOptions: parsed.fetchOptions
1870
+ },
1871
+ options
1872
+ );
1873
+ };
1874
+ const adminUserSessionRevokeBinding = (input, options) => {
1875
+ const requireUserId = (userId) => {
1876
+ const trimmed = String(userId ?? "").trim();
1877
+ if (!trimmed) {
1878
+ throw new Error("admin.user.session.revoke requires a non-empty userId");
1879
+ }
1880
+ return trimmed;
1881
+ };
1882
+ const requireSinglePluralUserId = (sessions2) => {
1883
+ const uniqueUserIds = [...new Set(sessions2.map((session) => requireUserId(session.userId)))];
1884
+ if (uniqueUserIds.length !== 1) {
1885
+ throw new Error("admin.user.session.revoke requires the same userId across plural payloads");
1886
+ }
1887
+ return { userId: uniqueUserIds[0] };
1888
+ };
1889
+ if (Array.isArray(input)) {
1890
+ if (input.length === 0) {
1891
+ throw new Error("admin.user.session.revoke requires at least one payload item");
1892
+ }
1893
+ if (input.length === 1) {
1894
+ return postGeneric(
1895
+ "/admin/revoke-user-session",
1896
+ {
1897
+ ...input[0],
1898
+ userId: requireUserId(input[0].userId)
1899
+ },
1900
+ options
1901
+ );
1902
+ }
1903
+ return postGeneric(
1904
+ "/admin/revoke-user-sessions",
1905
+ requireSinglePluralUserId(input),
1906
+ options
1907
+ );
1908
+ }
1909
+ const parsed = input;
1910
+ const sessions = parsed.sessions;
1911
+ if (sessions && sessions.length === 0) {
1912
+ throw new Error("admin.user.session.revoke requires at least one payload item");
1913
+ }
1914
+ if (sessions && sessions.length === 1) {
1915
+ return postGeneric(
1916
+ "/admin/revoke-user-session",
1917
+ {
1918
+ ...sessions[0],
1919
+ userId: requireUserId(sessions[0].userId),
1920
+ fetchOptions: parsed.fetchOptions
1921
+ },
1922
+ options
1923
+ );
1924
+ }
1925
+ if (sessions && sessions.length > 1) {
1926
+ return postGeneric(
1927
+ "/admin/revoke-user-sessions",
1928
+ {
1929
+ ...requireSinglePluralUserId(sessions),
1930
+ fetchOptions: parsed.fetchOptions
1931
+ },
1932
+ options
1933
+ );
1934
+ }
1935
+ const normalizedUserId = requireUserId(parsed.userId);
1936
+ if (!parsed.sessionToken) {
1937
+ return postGeneric(
1938
+ "/admin/revoke-user-sessions",
1939
+ {
1940
+ userId: normalizedUserId,
1941
+ fetchOptions: parsed.fetchOptions
1942
+ },
1943
+ options
1944
+ );
1945
+ }
1946
+ return postGeneric(
1947
+ "/admin/revoke-user-session",
1948
+ {
1949
+ ...parsed,
1950
+ userId: normalizedUserId
1951
+ },
1952
+ options
1953
+ );
1954
+ };
1955
+ const auth = {
1956
+ getSession: (input, options) => getGeneric("/get-session", input, options),
1957
+ signOut,
1958
+ forgetPassword: (input, options) => postGeneric("/forget-password", input, options),
1959
+ resetPassword: authResetPassword,
1960
+ setPassword: (input, options) => postGeneric("/set-password", input, options),
1961
+ verifyEmail: (input, options) => {
1962
+ const queryInput = {
1963
+ query: {
1964
+ token: input.token,
1965
+ callbackURL: input.callbackURL
1966
+ },
1967
+ fetchOptions: input.fetchOptions
1968
+ };
1969
+ return getWithQuery(
1970
+ "/verify-email",
1971
+ queryInput,
1972
+ options
1973
+ );
1974
+ },
1975
+ sendVerificationEmail: (input, options) => postGeneric("/send-verification-email", input, options),
1976
+ changeEmail: (input, options) => postGeneric("/change-email", input, options),
1977
+ changeEmailVerify: (input, options) => getWithQuery("/change-email/verify", input, options),
1978
+ deleteUserVerify: (input, options) => getWithQuery("/delete-user/verify", input, options),
1979
+ changePassword: (input, options) => postGeneric("/change-password", input, options),
1980
+ user: {
1981
+ update: (input, options) => postGeneric("/update-user", input, options),
1982
+ delete: (input, options) => postGeneric("/delete-user", input, options),
1983
+ email: {
1984
+ list: listUserEmailsWithFallback
1985
+ }
1986
+ },
1987
+ session: {
1988
+ list: (input, options) => getGeneric("/list-sessions", input, options),
1989
+ revoke: sessionRevokeBinding,
1990
+ revokeOther: revokeOtherSessions
1991
+ },
1992
+ social: {
1993
+ link: (input, options) => postGeneric("/link-social", input, options)
1994
+ },
1995
+ account: {
1996
+ list: (input, options) => getGeneric("/list-accounts", input, options),
1997
+ unlink: (input, options) => postGeneric("/unlink-account", input, options)
1998
+ },
1999
+ deleteUser: {
2000
+ callback: deleteUserCallback
2001
+ },
2002
+ refreshToken: (input, options) => postGeneric("/refresh-token", input, options),
2003
+ getAccessToken: (input, options) => postGeneric("/get-access-token", input, options),
2004
+ health: healthWithFallback,
2005
+ ok: (input, options) => getGeneric("/ok", input, options),
2006
+ error: (input, options) => getGeneric("/error", input, options),
2007
+ twoFactor: {
2008
+ getTotpUri: (input, options) => postGeneric("/two-factor/get-totp-uri", input, options),
2009
+ verifyTotp: (input, options) => postGeneric("/two-factor/verify-totp", input, options),
2010
+ sendOtp: (input, options) => postGeneric("/two-factor/send-otp", input, options),
2011
+ verifyOtp: (input, options) => postGeneric("/two-factor/verify-otp", input, options),
2012
+ verifyBackupCode: (input, options) => postGeneric("/two-factor/verify-backup-code", input, options),
2013
+ generateBackupCodes: (input, options) => executePostWithCompatibleInput(
2014
+ resolvedConfig,
2015
+ { endpoint: "/two-factor/generate-backup-codes", method: "POST" },
2016
+ input,
2017
+ options
2018
+ ),
2019
+ enable: (input, options) => postGeneric("/two-factor/enable", input, options),
2020
+ disable: (input, options) => postGeneric("/two-factor/disable", input, options)
2021
+ },
2022
+ passkey: {
2023
+ generateRegisterOptions: (input, options) => getGeneric("/passkey/generate-register-options", input, options),
2024
+ generateAuthenticateOptions: (input, options) => postGeneric("/passkey/generate-authenticate-options", input, options),
2025
+ verifyRegistration: (input, options) => postGeneric("/passkey/verify-registration", input, options),
2026
+ verifyAuthentication: (input, options) => postGeneric("/passkey/verify-authentication", input, options),
2027
+ listUserPasskeys: (input, options) => getGeneric("/passkey/list-user-passkeys", input, options),
2028
+ deletePasskey: (input, options) => postGeneric("/passkey/delete-passkey", input, options),
2029
+ updatePasskey: (input, options) => postGeneric("/passkey/update-passkey", input, options),
2030
+ getRelatedOrigins: (input, options) => getGeneric("/.well-known/webauthn", input, options)
2031
+ },
2032
+ admin: {
2033
+ role: {
2034
+ set: (input, options) => postGeneric("/admin/set-role", input, options)
2035
+ },
2036
+ user: {
2037
+ list: (input, options) => getWithQuery("/admin/list-users", input, options),
2038
+ create: (input, options) => postGeneric("/admin/create-user", input, options),
2039
+ unban: (input, options) => postGeneric("/admin/unban-user", input, options),
2040
+ ban: (input, options) => postGeneric("/admin/ban-user", input, options),
2041
+ impersonate: (input, options) => postGeneric("/admin/impersonate-user", input, options),
2042
+ stopImpersonating: (input, options) => postGeneric("/admin/stop-impersonating", input, options),
2043
+ remove: (input, options) => postGeneric("/admin/remove-user", input, options),
2044
+ setPassword: (input, options) => postGeneric("/admin/set-user-password", input, options),
2045
+ session: {
2046
+ list: (input, options) => postGeneric("/admin/list-user-sessions", input, options),
2047
+ revoke: adminUserSessionRevokeBinding
2048
+ }
2049
+ },
2050
+ hasPermission: (input, options) => postGeneric("/admin/has-permission", input, options),
2051
+ apiKey: {
2052
+ create: (input, options) => postGeneric("/admin/api-key/create", input, options)
2053
+ },
2054
+ athenaClient: {
2055
+ create: (input, options) => postGeneric("/admin/athena-client/create", input, options),
2056
+ list: (input, options) => getWithQuery("/admin/athena-client/list", input, options)
2057
+ },
2058
+ auditLog: {
2059
+ list: (input, options) => getWithQuery("/admin/audit-log/list", input, options)
2060
+ },
2061
+ email: {
2062
+ list: (input, options) => getWithQuery("/admin/email/list", input, options),
2063
+ get: (input, options) => getWithQuery("/admin/email/get", input, options),
2064
+ create: (input, options) => postGeneric("/admin/email/create", input, options),
2065
+ update: (input, options) => postGeneric("/admin/email/update", input, options),
2066
+ delete: (input, options) => postGeneric("/admin/email/delete", input, options),
2067
+ failure: {
2068
+ list: (input, options) => getWithQuery("/admin/email-failure/list", input, options),
2069
+ get: (input, options) => getWithQuery("/admin/email-failure/get", input, options),
2070
+ create: (input, options) => postGeneric("/admin/email-failure/create", input, options),
2071
+ update: (input, options) => postGeneric("/admin/email-failure/update", input, options),
2072
+ delete: (input, options) => postGeneric("/admin/email-failure/delete", input, options)
2073
+ },
2074
+ template: {
2075
+ list: (input, options) => getWithQuery("/admin/email-template/list", input, options),
2076
+ get: (input, options) => getWithQuery("/admin/email-template/get", input, options),
2077
+ create: (input, options) => postGeneric("/admin/email-template/create", input, options),
2078
+ update: (input, options) => postGeneric("/admin/email-template/update", input, options),
2079
+ delete: (input, options) => postGeneric("/admin/email-template/delete", input, options)
2080
+ }
2081
+ },
2082
+ emailTemplate: {
2083
+ get: (input, options) => getWithQuery("/admin/email-template/get", input, options),
2084
+ create: (input, options) => postGeneric("/admin/email-template/create", input, options),
2085
+ delete: (input, options) => postGeneric("/admin/email-template/delete", input, options),
2086
+ list: (input, options) => getWithQuery("/admin/email-template/list", input, options),
2087
+ update: (input, options) => postGeneric("/admin/email-template/update", input, options)
2088
+ }
2089
+ },
2090
+ apiKey: {
2091
+ create: (input, options) => postGeneric("/api-key/create", input, options),
2092
+ get: (input, options) => getWithQuery("/api-key/get", input, options),
2093
+ update: (input, options) => postGeneric("/api-key/update", input, options),
2094
+ delete: (input, options) => postGeneric("/api-key/delete", input, options),
2095
+ list: (input, options) => getWithQuery("/api-key/list", input, options),
2096
+ verify: (input, options) => postGeneric("/api-key/verify", input, options),
2097
+ deleteAllExpired: (input, options) => executePostWithOptionalInput(
2098
+ resolvedConfig,
2099
+ { endpoint: "/api-key/delete-all-expired-api-keys", method: "POST" },
2100
+ input,
2101
+ options
2102
+ )
2103
+ },
2104
+ signIn: {
2105
+ email: (input, options) => postGeneric("/sign-in/email", input, options),
2106
+ username: (input, options) => postGeneric("/sign-in/username", input, options),
2107
+ social: (input, options) => postGeneric("/sign-in/social", input, options)
2108
+ },
2109
+ signUp: {
2110
+ email: (input, options) => postGeneric("/sign-up/email", input, options)
2111
+ },
2112
+ organization,
2113
+ callback: {
2114
+ provider: (input, options) => {
2115
+ const { payload, fetchOptions } = extractFetchOptions(input);
2116
+ const parsed = payload;
2117
+ const provider = String(parsed?.provider ?? "").trim();
2118
+ if (!provider) {
2119
+ throw new Error("callback.provider requires a non-empty provider value");
2120
+ }
2121
+ const code = String(parsed?.code ?? "").trim();
2122
+ const state = String(parsed?.state ?? "").trim();
2123
+ if (!code || !state) {
2124
+ throw new Error("callback.provider requires non-empty code and state values");
2125
+ }
2126
+ const endpoint = `/callback/${encodeURIComponent(provider)}`;
2127
+ return request({
2128
+ endpoint,
2129
+ method: "GET",
2130
+ query: {
2131
+ code,
2132
+ state
2133
+ },
2134
+ fetchOptions
2135
+ }, options);
2136
+ }
2137
+ }
2138
+ };
2139
+ return {
2140
+ baseUrl: normalizedBaseUrl,
2141
+ request,
2142
+ signIn: {
2143
+ email: (input, options) => executePostWithCompatibleInput(
2144
+ resolvedConfig,
2145
+ { endpoint: "/sign-in/email", method: "POST" },
2146
+ input,
2147
+ options
2148
+ ),
2149
+ username: (input, options) => executePostWithCompatibleInput(
2150
+ resolvedConfig,
2151
+ { endpoint: "/sign-in/username", method: "POST" },
2152
+ input,
2153
+ options
2154
+ ),
2155
+ social: (input, options) => executePostWithCompatibleInput(
2156
+ resolvedConfig,
2157
+ { endpoint: "/sign-in/social", method: "POST" },
2158
+ input,
2159
+ options
2160
+ )
2161
+ },
2162
+ signUp: {
2163
+ email: (input, options) => executePostWithCompatibleInput(
2164
+ resolvedConfig,
2165
+ { endpoint: "/sign-up/email", method: "POST" },
2166
+ input,
2167
+ options
2168
+ )
2169
+ },
2170
+ signOut,
2171
+ logout: signOut,
2172
+ getSession: (input, options) => executeGetWithCompatibleInput(
2173
+ resolvedConfig,
2174
+ { endpoint: "/get-session", method: "GET" },
2175
+ input,
2176
+ options
2177
+ ),
2178
+ listSessions: (input, options) => executeGetWithCompatibleInput(
2179
+ resolvedConfig,
2180
+ { endpoint: "/list-sessions", method: "GET" },
2181
+ input,
2182
+ options
2183
+ ),
2184
+ revokeSession,
2185
+ clearSession: revokeSession,
2186
+ revokeSessions,
2187
+ clearSessions: revokeSessions,
2188
+ revokeOtherSessions,
2189
+ clearOtherSessions: revokeOtherSessions,
2190
+ forgetPassword: (input, options) => executePostWithCompatibleInput(
2191
+ resolvedConfig,
2192
+ { endpoint: "/forget-password", method: "POST" },
2193
+ input,
2194
+ options
2195
+ ),
2196
+ resetPassword: (input, options) => executePostWithCompatibleInput(
2197
+ resolvedConfig,
2198
+ { endpoint: "/reset-password", method: "POST" },
2199
+ input,
2200
+ options
2201
+ ),
2202
+ resolveResetPasswordToken,
2203
+ verifyEmail: (input, options) => {
2204
+ const { payload, fetchOptions } = extractFetchOptions(input);
2205
+ const mergedOptions = mergeCallOptions(fetchOptions, options);
2206
+ const query = payload;
2207
+ return callAuthEndpoint(
2208
+ resolvedConfig,
2209
+ { endpoint: "/verify-email", method: "GET" },
2210
+ void 0,
2211
+ query ? {
2212
+ token: query.token,
2213
+ callbackURL: query.callbackURL
2214
+ } : void 0,
2215
+ mergedOptions
2216
+ );
2217
+ },
2218
+ sendVerificationEmail: (input, options) => executePostWithCompatibleInput(
2219
+ resolvedConfig,
2220
+ { endpoint: "/send-verification-email", method: "POST" },
2221
+ input,
2222
+ options
2223
+ ),
2224
+ changeEmail: (input, options) => executePostWithCompatibleInput(
2225
+ resolvedConfig,
2226
+ { endpoint: "/change-email", method: "POST" },
2227
+ input,
2228
+ options
2229
+ ),
2230
+ changePassword: (input, options) => executePostWithCompatibleInput(
2231
+ resolvedConfig,
2232
+ { endpoint: "/change-password", method: "POST" },
2233
+ input,
2234
+ options
2235
+ ),
2236
+ updateUser: (input, options) => executePostWithCompatibleInput(
2237
+ resolvedConfig,
2238
+ { endpoint: "/update-user", method: "POST" },
2239
+ input,
2240
+ options
2241
+ ),
2242
+ deleteUser,
2243
+ deleteUserCallback,
2244
+ linkSocial: (input, options) => executePostWithCompatibleInput(
2245
+ resolvedConfig,
2246
+ { endpoint: "/link-social", method: "POST" },
2247
+ input,
2248
+ options
2249
+ ),
2250
+ listAccounts: (input, options) => executeGetWithCompatibleInput(
2251
+ resolvedConfig,
2252
+ { endpoint: "/list-accounts", method: "GET" },
2253
+ input,
2254
+ options
2255
+ ),
2256
+ unlinkAccount: (input, options) => executePostWithCompatibleInput(
2257
+ resolvedConfig,
2258
+ { endpoint: "/unlink-account", method: "POST" },
2259
+ input,
2260
+ options
2261
+ ),
2262
+ refreshToken: (input, options) => executePostWithCompatibleInput(
2263
+ resolvedConfig,
2264
+ { endpoint: "/refresh-token", method: "POST" },
2265
+ input,
2266
+ options
2267
+ ),
2268
+ getAccessToken: (input, options) => executePostWithCompatibleInput(
2269
+ resolvedConfig,
2270
+ { endpoint: "/get-access-token", method: "POST" },
2271
+ input,
2272
+ options
2273
+ ),
2274
+ organization,
2275
+ auth
2276
+ };
2277
+ }
2278
+
1201
2279
  // src/client.ts
1202
2280
  var DEFAULT_COLUMNS = "*";
1203
2281
  var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
@@ -1936,6 +3014,7 @@ function createClientFromConfig(config) {
1936
3014
  backend: config.backend,
1937
3015
  headers: config.headers
1938
3016
  });
3017
+ const auth = createAuthClient(config.auth);
1939
3018
  return {
1940
3019
  from(table) {
1941
3020
  return createTableBuilder(table, gateway);
@@ -1952,7 +3031,8 @@ function createClientFromConfig(config) {
1952
3031
  gateway
1953
3032
  );
1954
3033
  },
1955
- query: createQueryBuilder(gateway)
3034
+ query: createQueryBuilder(gateway),
3035
+ auth: auth.auth
1956
3036
  };
1957
3037
  }
1958
3038
  var DEFAULT_BACKEND = { type: "athena" };
@@ -2026,7 +3106,11 @@ function createClient(url, apiKey, options) {
2026
3106
  const b = AthenaClient.builder().url(url).key(apiKey).backend(toBackendConfig(options?.backend));
2027
3107
  if (options?.client) b.client(options.client);
2028
3108
  if (options?.headers && Object.keys(options.headers).length > 0) b.headers(options.headers);
2029
- return b.build();
3109
+ const client = b.build();
3110
+ if (options?.auth) {
3111
+ client.auth = createAuthClient(options.auth).auth;
3112
+ }
3113
+ return client;
2030
3114
  }
2031
3115
 
2032
3116
  // src/schema/postgres-introspection-core.ts