@xylex-group/athena 3.1.0 → 3.5.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 (100) hide show
  1. package/README.md +17 -1
  2. package/dist/admin.cjs +55 -1
  3. package/dist/admin.cjs.map +1 -1
  4. package/dist/admin.d.cts +32 -8
  5. package/dist/admin.d.ts +32 -8
  6. package/dist/admin.js +54 -2
  7. package/dist/admin.js.map +1 -1
  8. package/dist/athena-auth-url-C1FbVmN6.d.cts +200 -0
  9. package/dist/athena-auth-url-C1FbVmN6.d.ts +200 -0
  10. package/dist/{athena-request-headers-C7Jy-c_D.d.ts → athena-request-headers-BnFN2mbd.d.cts} +49 -201
  11. package/dist/{athena-request-headers-DujFFyMU.d.cts → athena-request-headers-Dwdkq2WR.d.ts} +49 -201
  12. package/dist/billing.cjs +1 -1
  13. package/dist/billing.cjs.map +1 -1
  14. package/dist/billing.js +1 -1
  15. package/dist/billing.js.map +1 -1
  16. package/dist/browser.cjs +3735 -248
  17. package/dist/browser.cjs.map +1 -1
  18. package/dist/browser.d.cts +11 -10
  19. package/dist/browser.d.ts +11 -10
  20. package/dist/browser.js +3726 -249
  21. package/dist/browser.js.map +1 -1
  22. package/dist/cli/index.cjs +3232 -190
  23. package/dist/cli/index.cjs.map +1 -1
  24. package/dist/cli/index.d.cts +4 -4
  25. package/dist/cli/index.d.ts +4 -4
  26. package/dist/cli/index.js +3232 -190
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/cloudflare.cjs +12914 -0
  29. package/dist/cloudflare.cjs.map +1 -0
  30. package/dist/cloudflare.d.cts +368 -0
  31. package/dist/cloudflare.d.ts +368 -0
  32. package/dist/cloudflare.js +12885 -0
  33. package/dist/cloudflare.js.map +1 -0
  34. package/dist/cookies.cjs +4 -3
  35. package/dist/cookies.cjs.map +1 -1
  36. package/dist/cookies.js +4 -3
  37. package/dist/cookies.js.map +1 -1
  38. package/dist/env.cjs +130 -0
  39. package/dist/env.cjs.map +1 -0
  40. package/dist/env.d.cts +70 -0
  41. package/dist/env.d.ts +70 -0
  42. package/dist/env.js +122 -0
  43. package/dist/env.js.map +1 -0
  44. package/dist/index.cjs +3749 -241
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.cts +11 -10
  47. package/dist/index.d.ts +11 -10
  48. package/dist/index.js +3739 -242
  49. package/dist/index.js.map +1 -1
  50. package/dist/{model-form-BhWWsA-7.d.cts → model-form-D0ykVVOs.d.cts} +26 -4
  51. package/dist/{model-form-BbdzJ9Uh.d.ts → model-form-U8NVtfSA.d.ts} +26 -4
  52. package/dist/{module-xFd7_Igv.d.cts → module-CMWlJ1z3.d.cts} +5 -5
  53. package/dist/{module-DKkJKOuJ.d.ts → module-CZ-wPcf2.d.ts} +5 -5
  54. package/dist/next/client.cjs +3212 -196
  55. package/dist/next/client.cjs.map +1 -1
  56. package/dist/next/client.d.cts +6 -5
  57. package/dist/next/client.d.ts +6 -5
  58. package/dist/next/client.js +3212 -196
  59. package/dist/next/client.js.map +1 -1
  60. package/dist/next/server.cjs +4461 -781
  61. package/dist/next/server.cjs.map +1 -1
  62. package/dist/next/server.d.cts +139 -13
  63. package/dist/next/server.d.ts +139 -13
  64. package/dist/next/server.js +4451 -782
  65. package/dist/next/server.js.map +1 -1
  66. package/dist/{pipeline-DuKzYGia.d.cts → pipeline-BCpb4BX1.d.cts} +1 -1
  67. package/dist/{pipeline-wer2G9xW.d.ts → pipeline-CgmXwMeX.d.ts} +1 -1
  68. package/dist/{proxy-request-headers-m4D2Tduy.d.ts → proxy-request-headers-CttlcuRb.d.ts} +1 -1
  69. package/dist/{proxy-request-headers-DGxdoyA0.d.cts → proxy-request-headers-pIBSn1Fw.d.cts} +1 -1
  70. package/dist/react.cjs +290 -31
  71. package/dist/react.cjs.map +1 -1
  72. package/dist/react.d.cts +62 -12
  73. package/dist/react.d.ts +62 -12
  74. package/dist/react.js +290 -32
  75. package/dist/react.js.map +1 -1
  76. package/dist/schema-handlers-CvWqF-dW.d.ts +138 -0
  77. package/dist/schema-handlers-Dr8h9Jg-.d.cts +138 -0
  78. package/dist/social-providers.cjs +1 -1
  79. package/dist/social-providers.cjs.map +1 -1
  80. package/dist/social-providers.d.cts +1 -1
  81. package/dist/social-providers.d.ts +1 -1
  82. package/dist/social-providers.js +1 -1
  83. package/dist/social-providers.js.map +1 -1
  84. package/dist/{types-Bltx6iL6.d.ts → types-B2RZPivM.d.cts} +8 -1
  85. package/dist/{types-Bltx6iL6.d.cts → types-B2RZPivM.d.ts} +8 -1
  86. package/dist/{types-1ztXDgPa.d.cts → types-BKklrX4J.d.ts} +14 -2
  87. package/dist/{types-AOY-GLu8.d.cts → types-BVKpQmfY.d.cts} +11 -0
  88. package/dist/{types-AOY-GLu8.d.ts → types-BVKpQmfY.d.ts} +11 -0
  89. package/dist/{types-CgCv5o6R.d.cts → types-D5dj1v5Z.d.cts} +1 -1
  90. package/dist/{types-CccOiXPo.d.ts → types-DqBFwfhn.d.cts} +14 -2
  91. package/dist/{types-B75PdABb.d.ts → types-S-bTMPiM.d.ts} +1 -1
  92. package/dist/utils.cjs +30 -0
  93. package/dist/utils.cjs.map +1 -1
  94. package/dist/utils.d.cts +4 -3
  95. package/dist/utils.d.ts +4 -3
  96. package/dist/utils.js +30 -1
  97. package/dist/utils.js.map +1 -1
  98. package/dist/{v3-client-CWfZHcKL.d.cts → v3-client-DP-qg82X.d.cts} +323 -5
  99. package/dist/{v3-client-DZp2NEhK.d.ts → v3-client-OAai_JNs.d.ts} +323 -5
  100. package/package.json +25 -4
package/dist/react.js CHANGED
@@ -392,7 +392,7 @@ function buildAthenaRequestHeaders(input) {
392
392
 
393
393
  // package.json
394
394
  var package_default = {
395
- version: "3.1.0"
395
+ version: "3.5.1"
396
396
  };
397
397
 
398
398
  // src/sdk-version.ts
@@ -1043,7 +1043,8 @@ function stableSerialize(value, seen) {
1043
1043
  if (value === void 0) return "undefined";
1044
1044
  const valueType = typeof value;
1045
1045
  if (valueType === "string") return `"${value}"`;
1046
- if (valueType === "number") return Number.isFinite(value) ? String(value) : "null";
1046
+ if (valueType === "number")
1047
+ return Number.isFinite(value) ? String(value) : "null";
1047
1048
  if (valueType === "boolean") return value ? "true" : "false";
1048
1049
  if (valueType === "bigint") return `${String(value)}n`;
1049
1050
  if (valueType === "symbol") return `symbol:${String(value)}`;
@@ -1124,7 +1125,8 @@ async function runWithRetry(execute, options) {
1124
1125
  }
1125
1126
  function errorMessageFromUnknown(error) {
1126
1127
  if (typeof error === "string" && error.trim()) return error.trim();
1127
- if (error instanceof Error && error.message.trim()) return error.message.trim();
1128
+ if (error instanceof Error && error.message.trim())
1129
+ return error.message.trim();
1128
1130
  if (isRecord2(error)) {
1129
1131
  const messageCandidate = error.message ?? error.error;
1130
1132
  if (typeof messageCandidate === "string" && messageCandidate.trim()) {
@@ -1343,7 +1345,11 @@ var AthenaQueryClient = class {
1343
1345
  const key = this.getMutationKeyToken(mutationKey);
1344
1346
  const entry = this.ensureMutationEntry(key);
1345
1347
  entry.activeRequestId = ++this.requestCounter;
1346
- this.setMutationState(entry, createInitialMutationState(), "mutation_reset");
1348
+ this.setMutationState(
1349
+ entry,
1350
+ createInitialMutationState(),
1351
+ "mutation_reset"
1352
+ );
1347
1353
  }
1348
1354
  async executeQuery(input) {
1349
1355
  const entry = this.ensureQueryEntry(input.queryKeyToken);
@@ -1405,7 +1411,10 @@ var AthenaQueryClient = class {
1405
1411
  );
1406
1412
  }
1407
1413
  const rawResult = await input.queryFn();
1408
- const normalized = normalizeAthenaResult(rawResult, input.select);
1414
+ const normalized = normalizeAthenaResult(
1415
+ rawResult,
1416
+ input.select
1417
+ );
1409
1418
  if (normalized.error) {
1410
1419
  throw {
1411
1420
  __athenaNormalizedError: normalized.error,
@@ -1493,7 +1502,10 @@ var AthenaQueryClient = class {
1493
1502
  this.inflightQueries.delete(input.queryKeyToken);
1494
1503
  }
1495
1504
  });
1496
- this.inflightQueries.set(input.queryKeyToken, executionPromise);
1505
+ this.inflightQueries.set(
1506
+ input.queryKeyToken,
1507
+ executionPromise
1508
+ );
1497
1509
  return executionPromise;
1498
1510
  }
1499
1511
  async executeMutation(input) {
@@ -1539,7 +1551,10 @@ var AthenaQueryClient = class {
1539
1551
  );
1540
1552
  }
1541
1553
  const rawResult = await input.mutationFn(input.variables);
1542
- const normalized = normalizeAthenaResult(rawResult, input.select);
1554
+ const normalized = normalizeAthenaResult(
1555
+ rawResult,
1556
+ input.select
1557
+ );
1543
1558
  if (normalized.error) {
1544
1559
  throw {
1545
1560
  __athenaNormalizedError: normalized.error,
@@ -2164,12 +2179,6 @@ function applyAthenaReadQuerySelectOrder(queryBuilder, orderBy) {
2164
2179
  queryBuilder
2165
2180
  );
2166
2181
  }
2167
- function applyAthenaReadQuerySelectLimit(queryBuilder, limit) {
2168
- if (!limit || limit < 1) {
2169
- return queryBuilder;
2170
- }
2171
- return queryBuilder.limit(limit);
2172
- }
2173
2182
  function clampAthenaReadQueryTotalItems(totalItems, limit) {
2174
2183
  if (!limit || limit < 1) {
2175
2184
  return totalItems;
@@ -2202,6 +2211,27 @@ function resolveTotalItemsFromPage({
2202
2211
  }
2203
2212
  return clampAthenaReadQueryTotalItems(exactCount, limit);
2204
2213
  }
2214
+ function resolveAthenaReadQueryPageFetch({
2215
+ page,
2216
+ pageSize,
2217
+ limit
2218
+ }) {
2219
+ const safePage = Math.max(1, Math.trunc(page) || 1);
2220
+ const safePageSize = Math.max(1, Math.trunc(pageSize) || 1);
2221
+ if (!limit || limit < 1) {
2222
+ return { page: safePage, pageSize: safePageSize, shouldFetch: true };
2223
+ }
2224
+ const totalCap = Math.trunc(limit);
2225
+ const offset = (safePage - 1) * safePageSize;
2226
+ if (offset >= totalCap) {
2227
+ return { page: safePage, pageSize: safePageSize, shouldFetch: false };
2228
+ }
2229
+ return {
2230
+ page: safePage,
2231
+ pageSize: Math.min(safePageSize, totalCap - offset),
2232
+ shouldFetch: true
2233
+ };
2234
+ }
2205
2235
  async function executeAthenaReadQuery({
2206
2236
  client,
2207
2237
  page,
@@ -2220,15 +2250,29 @@ async function executeAthenaReadQuery({
2220
2250
  count: "exact",
2221
2251
  head: true
2222
2252
  });
2253
+ const pageFetch = resolveAthenaReadQueryPageFetch({
2254
+ limit: query.limit,
2255
+ page,
2256
+ pageSize
2257
+ });
2258
+ if (!pageFetch.shouldFetch) {
2259
+ return {
2260
+ rows: [],
2261
+ totalItems: resolveTotalItemsFromPage({
2262
+ countCandidates: [countResult.count],
2263
+ limit: query.limit,
2264
+ page: pageFetch.page,
2265
+ pageSize,
2266
+ rowCount: 0
2267
+ })
2268
+ };
2269
+ }
2223
2270
  if ((query.mode ?? "findMany") === "select") {
2224
- const selectBuilder = applyAthenaReadQuerySelectLimit(
2225
- applyAthenaReadQuerySelectOrder(
2226
- applyAthenaReadQueryFilters(baseBuilder, query.filters),
2227
- query.orderBy
2228
- ),
2229
- query.limit
2271
+ const selectBuilder = applyAthenaReadQuerySelectOrder(
2272
+ applyAthenaReadQueryFilters(baseBuilder, query.filters),
2273
+ query.orderBy
2230
2274
  );
2231
- const result2 = await selectBuilder.currentPage(page).pageSize(pageSize).select(buildAthenaReadQuerySelectString(query.columns), {
2275
+ const result2 = await selectBuilder.currentPage(pageFetch.page).pageSize(pageFetch.pageSize).select(buildAthenaReadQuerySelectString(query.columns), {
2232
2276
  count: "exact"
2233
2277
  });
2234
2278
  const rows2 = flattenAthenaReadQueryRows(
@@ -2242,7 +2286,7 @@ async function executeAthenaReadQuery({
2242
2286
  totalItems: resolveTotalItemsFromPage({
2243
2287
  countCandidates: [countResult.count, result2.count],
2244
2288
  limit: query.limit,
2245
- page,
2289
+ page: pageFetch.page,
2246
2290
  pageSize,
2247
2291
  rowCount: rows2.length
2248
2292
  })
@@ -2250,12 +2294,11 @@ async function executeAthenaReadQuery({
2250
2294
  }
2251
2295
  const findManyOrderBy = buildAthenaReadQueryFindManyOrderBy(query.orderBy);
2252
2296
  const findManyOptions = {
2253
- ...query.limit ? { limit: query.limit } : {},
2254
2297
  ...findManyOrderBy ? { orderBy: findManyOrderBy } : {},
2255
2298
  select: buildAthenaReadQueryFindManySelect(query.columns),
2256
2299
  ...query.filters?.length ? { where: buildAthenaReadQueryFindManyWhere(query.filters) } : {}
2257
2300
  };
2258
- const result = await baseBuilder.currentPage(page).pageSize(pageSize).findMany(findManyOptions);
2301
+ const result = await baseBuilder.currentPage(pageFetch.page).pageSize(pageFetch.pageSize).findMany(findManyOptions);
2259
2302
  const rows = flattenAthenaReadQueryRows(
2260
2303
  Array.isArray(result.data) ? result.data : [],
2261
2304
  query.columns,
@@ -2267,7 +2310,7 @@ async function executeAthenaReadQuery({
2267
2310
  totalItems: resolveTotalItemsFromPage({
2268
2311
  countCandidates: [countResult.count, result.count],
2269
2312
  limit: query.limit,
2270
- page,
2313
+ page: pageFetch.page,
2271
2314
  pageSize,
2272
2315
  rowCount: rows.length
2273
2316
  })
@@ -2379,7 +2422,16 @@ function resolveGetSession(authClient) {
2379
2422
  if ("auth" in authClient && authClient.auth && typeof authClient.auth.getSession === "function") {
2380
2423
  return authClient.auth.getSession;
2381
2424
  }
2382
- throw new Error("useSession requires an auth-capable client (createClient(...).auth)");
2425
+ throw new Error(
2426
+ "useSession requires an auth-capable client (createClient(...).auth)"
2427
+ );
2428
+ }
2429
+ function toFallbackErrorDetails(code, message, status) {
2430
+ return {
2431
+ code,
2432
+ message,
2433
+ status
2434
+ };
2383
2435
  }
2384
2436
  function useSession(authClient, options = {}) {
2385
2437
  const enabled = options.enabled ?? true;
@@ -2397,11 +2449,6 @@ function useSession(authClient, options = {}) {
2397
2449
  useEffect(() => {
2398
2450
  dataRef.current = data;
2399
2451
  }, [data]);
2400
- const toFallbackErrorDetails = (code, message, status) => ({
2401
- code,
2402
- message,
2403
- status
2404
- });
2405
2452
  const runFetch = useCallback(async () => {
2406
2453
  const requestId = ++requestIdRef.current;
2407
2454
  const hasData = dataRef.current !== null;
@@ -2464,6 +2511,211 @@ function useSession(authClient, options = {}) {
2464
2511
  refetch
2465
2512
  };
2466
2513
  }
2514
+
2515
+ // src/admin/index.ts
2516
+ function resolveAdminPermissionClient(client) {
2517
+ if (!client || typeof client !== "object") {
2518
+ return null;
2519
+ }
2520
+ const record = client;
2521
+ const nestedAuth = record.auth;
2522
+ if (nestedAuth && typeof nestedAuth === "object" && nestedAuth !== null && "admin" in nestedAuth) {
2523
+ return client;
2524
+ }
2525
+ if ("admin" in record) {
2526
+ return { auth: client };
2527
+ }
2528
+ return null;
2529
+ }
2530
+ function buildAdminAuthFetchOptions(credentials = {}) {
2531
+ const cookie = credentials.cookie?.trim() || void 0;
2532
+ const bearerToken = credentials.bearerToken?.trim() || void 0;
2533
+ const headers = {};
2534
+ if (cookie) {
2535
+ headers.cookie = cookie;
2536
+ }
2537
+ if (bearerToken) {
2538
+ headers.authorization = `Bearer ${bearerToken}`;
2539
+ }
2540
+ return {
2541
+ credentials: "include",
2542
+ ...bearerToken ? { bearerToken } : {},
2543
+ ...Object.keys(headers).length > 0 ? { headers } : {}
2544
+ };
2545
+ }
2546
+ function hasAdminRole(session) {
2547
+ const role = session?.user?.role;
2548
+ if (!role) {
2549
+ return false;
2550
+ }
2551
+ return role.split(",").map((item) => item.trim().toLowerCase()).includes("admin");
2552
+ }
2553
+ function mergeAdminFetchOptions(input) {
2554
+ const fromCredentials = input.credentials ? buildAdminAuthFetchOptions(input.credentials) : void 0;
2555
+ const explicit = input.fetchOptions;
2556
+ if (!fromCredentials && !explicit) {
2557
+ return void 0;
2558
+ }
2559
+ if (!fromCredentials) {
2560
+ return explicit;
2561
+ }
2562
+ if (!explicit) {
2563
+ return fromCredentials;
2564
+ }
2565
+ return {
2566
+ ...fromCredentials,
2567
+ ...explicit,
2568
+ headers: {
2569
+ ...fromCredentials.headers ?? {},
2570
+ ...explicit.headers ?? {}
2571
+ }
2572
+ };
2573
+ }
2574
+ async function hasAdminPermission(client, input) {
2575
+ if (!input.session?.user?.id) {
2576
+ return false;
2577
+ }
2578
+ if (input.allowRoleBypass !== false && hasAdminRole(input.session)) {
2579
+ return true;
2580
+ }
2581
+ const fetchOptions = mergeAdminFetchOptions(input);
2582
+ const result = await client.auth.admin.hasPermission(
2583
+ {
2584
+ permission: input.permission,
2585
+ permissions: input.permissions,
2586
+ ...fetchOptions ? { fetchOptions } : {}
2587
+ },
2588
+ input.requestOptions
2589
+ );
2590
+ return Boolean(result.ok && result.data?.success);
2591
+ }
2592
+
2593
+ // src/react/use-admin-permission.ts
2594
+ var DEFAULT_ADMIN_PERMISSIONS = [
2595
+ "admin:read"
2596
+ ];
2597
+ function serializePermissions(permissions, permission) {
2598
+ return JSON.stringify({
2599
+ permission: permission ?? null,
2600
+ permissions: permissions ?? DEFAULT_ADMIN_PERMISSIONS
2601
+ });
2602
+ }
2603
+ function useAdminPermission(client, options = {}) {
2604
+ const enabled = options.enabled ?? true;
2605
+ const sessionProvided = "session" in options;
2606
+ const sessionFromOptions = sessionProvided ? options.session ?? null : void 0;
2607
+ const permissionsKey = serializePermissions(options.permissions, options.permission);
2608
+ const allowRoleBypass = options.allowRoleBypass;
2609
+ const fetchOptions = options.fetchOptions;
2610
+ const requestOptions = options.requestOptions;
2611
+ const optionsRef = useRef(options);
2612
+ optionsRef.current = options;
2613
+ const sessionState = useSession(client, {
2614
+ ...options.sessionOptions,
2615
+ enabled: enabled && !sessionProvided && !!client
2616
+ });
2617
+ const session = sessionProvided ? sessionFromOptions ?? null : sessionState.data;
2618
+ const sessionPending = !sessionProvided && sessionState.isPending;
2619
+ const sessionUserId = session?.user?.id ?? null;
2620
+ const sessionRole = session?.user?.role ?? null;
2621
+ const [allowed, setAllowed] = useState(false);
2622
+ const [error, setError] = useState(null);
2623
+ const [isChecking, setIsChecking] = useState(enabled);
2624
+ const requestIdRef = useRef(0);
2625
+ const mountedRef = useRef(true);
2626
+ const runCheck = useCallback(async () => {
2627
+ const requestId = ++requestIdRef.current;
2628
+ const current = optionsRef.current;
2629
+ const permissions = current.permissions ?? DEFAULT_ADMIN_PERMISSIONS;
2630
+ if (!enabled || !client) {
2631
+ if (mountedRef.current && requestId === requestIdRef.current) {
2632
+ setAllowed(false);
2633
+ setError(null);
2634
+ setIsChecking(false);
2635
+ }
2636
+ return false;
2637
+ }
2638
+ setIsChecking(true);
2639
+ try {
2640
+ const permissionClient = resolveAdminPermissionClient(client);
2641
+ if (!permissionClient) {
2642
+ throw new Error(
2643
+ "useAdminPermission requires an Athena client with auth.admin (createClient(...) or auth bindings)"
2644
+ );
2645
+ }
2646
+ const resolvedSession = sessionProvided ? current.session ?? null : sessionState.data;
2647
+ const nextAllowed = await hasAdminPermission(permissionClient, {
2648
+ session: resolvedSession,
2649
+ permissions,
2650
+ permission: current.permission,
2651
+ allowRoleBypass: current.allowRoleBypass,
2652
+ fetchOptions: current.fetchOptions,
2653
+ requestOptions: current.requestOptions
2654
+ });
2655
+ if (!mountedRef.current || requestId !== requestIdRef.current) {
2656
+ return nextAllowed;
2657
+ }
2658
+ setAllowed(nextAllowed);
2659
+ setError(null);
2660
+ return nextAllowed;
2661
+ } catch (checkError) {
2662
+ if (!mountedRef.current || requestId !== requestIdRef.current) {
2663
+ return false;
2664
+ }
2665
+ const nextError = checkError instanceof Error ? checkError : new Error("Failed to resolve admin permission");
2666
+ setAllowed(false);
2667
+ setError(nextError);
2668
+ return false;
2669
+ } finally {
2670
+ if (mountedRef.current && requestId === requestIdRef.current) {
2671
+ setIsChecking(false);
2672
+ }
2673
+ }
2674
+ }, [client, enabled, sessionProvided, sessionState.data]);
2675
+ useEffect(() => {
2676
+ mountedRef.current = true;
2677
+ return () => {
2678
+ mountedRef.current = false;
2679
+ };
2680
+ }, []);
2681
+ useEffect(() => {
2682
+ if (!enabled) {
2683
+ setAllowed(false);
2684
+ setError(null);
2685
+ setIsChecking(false);
2686
+ return;
2687
+ }
2688
+ if (!sessionProvided && sessionState.isPending) {
2689
+ setIsChecking(true);
2690
+ return;
2691
+ }
2692
+ void runCheck();
2693
+ }, [
2694
+ allowRoleBypass,
2695
+ enabled,
2696
+ fetchOptions,
2697
+ permissionsKey,
2698
+ requestOptions,
2699
+ runCheck,
2700
+ sessionPending,
2701
+ sessionProvided,
2702
+ sessionRole,
2703
+ sessionUserId
2704
+ ]);
2705
+ const refetch = useCallback(async () => {
2706
+ if (!sessionProvided) {
2707
+ await sessionState.refetch();
2708
+ }
2709
+ return await runCheck();
2710
+ }, [runCheck, sessionProvided, sessionState]);
2711
+ return {
2712
+ allowed,
2713
+ isPending: enabled && (sessionPending || isChecking),
2714
+ error,
2715
+ session,
2716
+ refetch
2717
+ };
2718
+ }
2467
2719
  function useAthenaSessionClient(baseClient, options = {}) {
2468
2720
  const sessionState = useSession(baseClient, options);
2469
2721
  const scopedClient = useMemo(
@@ -2568,7 +2820,13 @@ function isStorageUploadInput(input) {
2568
2820
  return Boolean(input) && typeof input === "object" && "files" in input && "s3_id" in input;
2569
2821
  }
2570
2822
  function useStorageFiles(options) {
2571
- const { storage, input, enabled = true, callOptions, refreshIntervalMs } = options;
2823
+ const {
2824
+ storage,
2825
+ input,
2826
+ enabled = true,
2827
+ callOptions,
2828
+ refreshIntervalMs
2829
+ } = options;
2572
2830
  const [data, setData] = React.useState(null);
2573
2831
  const [loading, setLoading] = React.useState(false);
2574
2832
  const [error, setError] = React.useState(null);
@@ -2721,6 +2979,6 @@ function createModelFormAdapter(model) {
2721
2979
  };
2722
2980
  }
2723
2981
 
2724
- export { AthenaGatewayError, AthenaQueryClient, AthenaQueryClientProvider, attachStateAdapter, createAthenaQueryClient, createModelFormAdapter, isAthenaGatewayError, toModelFormDefaults, toModelPayload, useAthenaGateway, useAthenaQueryClient, useAthenaReadQuery, useAthenaSessionClient, useMutation, useQuery, useSession, useStorageFileDelete, useStorageFiles, useStorageUpload };
2982
+ export { AthenaGatewayError, AthenaQueryClient, AthenaQueryClientProvider, attachStateAdapter, createAthenaQueryClient, createModelFormAdapter, isAthenaGatewayError, toModelFormDefaults, toModelPayload, useAdminPermission, useAthenaGateway, useAthenaQueryClient, useAthenaReadQuery, useAthenaSessionClient, useMutation, useQuery, useSession, useStorageFileDelete, useStorageFiles, useStorageUpload };
2725
2983
  //# sourceMappingURL=react.js.map
2726
2984
  //# sourceMappingURL=react.js.map