@lunora/studio 1.0.0-alpha.1 → 1.0.0-alpha.10

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 (59) hide show
  1. package/__assets__/package-og.svg +1 -1
  2. package/dist/index.d.ts +15 -14
  3. package/dist/index.js +34 -34
  4. package/dist/mount.d.ts +1 -1
  5. package/dist/mount.js +1 -1
  6. package/dist/packem_shared/{ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js → ADMIN_FUNCTIONS-DjXgvJb6.js} +1 -0
  7. package/dist/packem_shared/{ApiDocsPanel-DpRjJhG5.js → ApiDocsPanel-yVSGHK3H.js} +3 -3
  8. package/dist/packem_shared/{ApiReferencePanel-DMIUp-kK.js → ApiReferencePanel-1vubqG5s.js} +2 -2
  9. package/dist/packem_shared/{ApiTab-DURGU15e.js → ApiTab-rwttyQ1-.js} +4 -4
  10. package/dist/packem_shared/{AuditPanel-BC59Nhst.js → AuditPanel-D9Eh7j7E.js} +19 -31
  11. package/dist/packem_shared/{CommandPalette-Dx_CoB9i.js → CommandPalette-BtgkBzZI.js} +2 -2
  12. package/dist/packem_shared/{ConfirmButton-WQVUoGFb.js → ConfirmButton-C2eVi2Qv.js} +1 -1
  13. package/dist/packem_shared/{ConnectionBadge-Bxagrip8.js → ConnectionBadge-B2DDM2Tn.js} +1 -1
  14. package/dist/packem_shared/{createStudioI18n-CgvlmDkN.js → DEFAULT_LOCALE-CiX4W7Kr.js} +1 -1
  15. package/dist/packem_shared/{DataBrowser-Coz6jJE6.js → DataBrowser-CyckZRwj.js} +115 -177
  16. package/dist/packem_shared/{ExportImportPanel-WO34fJxy.js → ExportImportPanel-BGJqFK9X.js} +9 -5
  17. package/dist/packem_shared/{FileBrowser-Zcr-Qgxo.js → FileBrowser-0pCpdKPE.js} +7 -7
  18. package/dist/packem_shared/{FunctionRunner-j0Rd5m9t.js → FunctionRunner-7NH3KcTg.js} +4 -4
  19. package/dist/packem_shared/{FunctionStatsPanel-DboBl-XL.js → FunctionStatsPanel-CXynSuqT.js} +141 -198
  20. package/dist/packem_shared/{GlobalDataBrowser-9MhPEfgN.js → GlobalDataBrowser-DAxzB-Br.js} +37 -66
  21. package/dist/packem_shared/{HealthPanel-DOIgbUtx.js → HealthPanel-CyLs7qZm.js} +31 -23
  22. package/dist/packem_shared/{HomePanel-bdOCNA-p.js → HomePanel-BOkFRbuj.js} +450 -389
  23. package/dist/packem_shared/{InsightsPanel-DaZPnSgt.js → InsightsPanel-CvXMoZuv.js} +104 -66
  24. package/dist/packem_shared/{LogsPanel-CWdqAGpQ.js → LogsPanel-BrUstOk6.js} +35 -47
  25. package/dist/packem_shared/{MailPanel-D_EGtDnS.js → MailPanel-GnnrNqL6.js} +31 -38
  26. package/dist/packem_shared/{MetricsPanel-E4Gv6wTO.js → MetricsPanel-BN_uUU-_.js} +34 -48
  27. package/dist/packem_shared/{MigrationsPanel-DQdPY9io.js → MigrationsPanel-DaZuUHje.js} +31 -38
  28. package/dist/packem_shared/{OpenRpcReferencePanel-j2p3HB0s.js → OpenRpcReferencePanel-vbcYbv3V.js} +2 -2
  29. package/dist/packem_shared/{PitrPanel-BbBkQR6t.js → PitrPanel-LJGNP_IX.js} +4 -4
  30. package/dist/packem_shared/{ScheduledJobs-Ok1CYYwI.js → ScheduledJobs-UmVaMbJy.js} +164 -61
  31. package/dist/packem_shared/{SchemaViewer-D8XGnp-X.js → SchemaViewer-Bam6ylvw.js} +4 -4
  32. package/dist/packem_shared/{SecurityAdvisorPanel-Cdm2IxLW.js → SecurityAdvisorPanel-DTmjUNqt.js} +44 -31
  33. package/dist/packem_shared/SettingsPanel-C2wDK-8F.js +390 -0
  34. package/dist/packem_shared/{ShardInput-DNCsT1KW.js → ShardInput-gx_DZXXn.js} +1 -1
  35. package/dist/packem_shared/SqlEditorPanel-D5wMIxcg.js +13 -0
  36. package/dist/packem_shared/Studio-DpgYe4qt.js +33 -0
  37. package/dist/packem_shared/{StudioApp-dvywkJ8I.js → StudioApp-C7aaizqc.js} +278 -4
  38. package/dist/packem_shared/{StudioI18nProvider-Dcajsznk.js → StudioI18nProvider-B-tDCZIi.js} +1 -1
  39. package/dist/packem_shared/{TableEditor-DIVDk3vT.js → TableEditor-DzK3Z6rL.js} +4 -4
  40. package/dist/packem_shared/{advisor-view-DBlzJi6C.js → advisor-view-CGcfMiPq.js} +1 -1
  41. package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-Nbhpihxv.d.ts} +1 -1
  42. package/dist/packem_shared/{cf-links-BZfRdxSE.js → cf-links-2cktDedA.js} +1 -1
  43. package/dist/packem_shared/{data-grid-CCh2Couo.js → data-grid-B5CaV3wS.js} +2 -2
  44. package/dist/packem_shared/{grid-features-DTjG6Sex.js → grid-features-CzUfqgsM.js} +3 -3
  45. package/dist/packem_shared/{internal-BBZYexre.js → internal-rXJEAhXS.js} +1 -1
  46. package/dist/packem_shared/{live-status-bPff1O7Y.js → live-status-FZ0psC1z.js} +1 -1
  47. package/dist/packem_shared/{reference-view-BCKIoai7.js → reference-view-B4E49Lip.js} +3 -3
  48. package/dist/packem_shared/{sql-editor-panel-CW2y2x9h.js → sql-editor-panel-Smfl_FDF.js} +6 -6
  49. package/dist/packem_shared/{studio-BDVd7rIV.js → studio-9Mq0PdMi.js} +2120 -1592
  50. package/dist/packem_shared/{table-list-sidebar-aZHLq70w.js → table-list-sidebar-Bg7uzbvC.js} +2 -2
  51. package/dist/packem_shared/use-admin-query-4JQW2rr1.js +88 -0
  52. package/dist/standalone/studio.js +176 -154
  53. package/dist/styles.css +1 -1
  54. package/package.json +13 -12
  55. package/dist/packem_shared/SettingsPanel-D3WF2mBU.js +0 -176
  56. package/dist/packem_shared/SqlEditorPanel-BuQ7f2Hs.js +0 -13
  57. package/dist/packem_shared/Studio-D36od9Oz.js +0 -33
  58. package/dist/packem_shared/use-live-admin-D1h1Fzsd.js +0 -73
  59. package/dist/packem_shared/use-live-shard-seed-B74RYcOy.js +0 -76
@@ -1,24 +1,24 @@
1
1
  import { c } from 'react/compiler-runtime';
2
2
  import { useLunora } from '@lunora/react';
3
3
  import { useState, useRef, useEffect, useMemo, useCallback } from 'react';
4
- import { ConfirmButton } from './ConfirmButton-WQVUoGFb.js';
5
- import { ShardInput } from './ShardInput-DNCsT1KW.js';
4
+ import { ConfirmButton } from './ConfirmButton-C2eVi2Qv.js';
5
+ import { ShardInput } from './ShardInput-gx_DZXXn.js';
6
6
  import { E as EmptyState } from './empty-state-DY_oe0k6.js';
7
- import { useT } from './createStudioI18n-CgvlmDkN.js';
8
- import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js';
9
- import { h as formatCell, f as fireAndForget, c as callOptions, a as adminRef, d as formatTimestamp } from './internal-BBZYexre.js';
7
+ import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
8
+ import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-DjXgvJb6.js';
9
+ import { h as formatCell, f as fireAndForget, c as callOptions, a as adminRef, b as formatTimestamp } from './internal-rXJEAhXS.js';
10
10
  import { useReactTable, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
11
11
  import { useVirtualizer } from '@tanstack/react-virtual';
12
12
  import { C as Checkbox } from './checkbox-UNkzAxl-.js';
13
13
  import { c as cn } from './utils-B05Dmz_H.js';
14
14
  import { f as flooredRectObserver } from './virtual-rect-CVMUskSm.js';
15
- import { G as GridContainer, C as CellValue, T as TransposedTable } from './data-grid-CCh2Couo.js';
15
+ import { G as GridContainer, C as CellValue, T as TransposedTable } from './data-grid-B5CaV3wS.js';
16
16
  import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
17
- import { u as useFacets, T as TableListSidebar, G as GridPagination, D as DataFacets } from './table-list-sidebar-aZHLq70w.js';
17
+ import { u as useFacets, T as TableListSidebar, G as GridPagination, D as DataFacets } from './table-list-sidebar-Bg7uzbvC.js';
18
18
  import { toFilterClauses, DataFilters } from './DataFilters-FNquMaiu.js';
19
- import { M as ModalShell, G as GridActionsBar, C as CellDetailDialog } from './grid-features-DTjG6Sex.js';
19
+ import { M as ModalShell, G as GridActionsBar, C as CellDetailDialog } from './grid-features-CzUfqgsM.js';
20
+ import { u as useAdminQuery } from './use-admin-query-4JQW2rr1.js';
20
21
  import useDebounced from './useDebounced-Dxncpg6z.js';
21
- import { u as useLiveAdmin } from './use-live-admin-D1h1Fzsd.js';
22
22
  import { r as recordShard, l as loadRecentShards } from './shard-history-DyebH1R5.js';
23
23
 
24
24
  const CAMEL_BOUNDARY_RE = /([a-z\d])([A-Z])/gu;
@@ -2160,12 +2160,12 @@ const fromOrderBy = (orderBy) => orderBy === void 0 ? [] : [{
2160
2160
  }];
2161
2161
  const MAX_BULK_DELETE_BATCHES = 200;
2162
2162
  const PREVIEW_CANDIDATES = 20;
2163
- const LIST_TABLES$1 = adminRef(ADMIN_FUNCTIONS.listTables);
2164
2163
  const READ_TABLE_PAGE$1 = adminRef(ADMIN_FUNCTIONS.readTablePage);
2165
2164
  const FACET_COLUMN = adminRef(ADMIN_FUNCTIONS.facetColumn);
2166
2165
  const WRITE_ROW$1 = adminRef(ADMIN_FUNCTIONS.writeRow);
2167
2166
  const DELETE_ROWS = adminRef(ADMIN_FUNCTIONS.deleteRows);
2168
2167
  const CLEAR_TABLE = adminRef(ADMIN_FUNCTIONS.clearTable);
2168
+ const NO_ARGS = {};
2169
2169
  const META_COLUMNS = /* @__PURE__ */ new Set(["__doc__", "__id__", "_creationTime", "_id", "id"]);
2170
2170
  const rowDocument = (row) => {
2171
2171
  const raw = row["__doc__"];
@@ -2205,12 +2205,8 @@ const useDataBrowser = ({
2205
2205
  search: initialSearch,
2206
2206
  table: tableParam
2207
2207
  });
2208
- const [tables, setTables] = useState(null);
2209
- const [tablesError, setTablesError] = useState(null);
2210
2208
  const [selectedTable, setSelectedTable] = useState(null);
2211
2209
  const [offset, setOffset] = useState(0);
2212
- const [page, setPage] = useState(null);
2213
- const [pageError, setPageError] = useState(null);
2214
2210
  const [viewMode, setViewMode] = useState("table");
2215
2211
  const [sorting, setSorting] = useState(() => fromOrderBy(initialOrderBy));
2216
2212
  const [filter, setFilter] = useState(initialSearch ?? "");
@@ -2225,87 +2221,46 @@ const useDataBrowser = ({
2225
2221
  refetchFacets,
2226
2222
  toggleFacet: toggleFacetColumn
2227
2223
  } = useFacets();
2228
- const sortingRef = useRef(sorting);
2229
- sortingRef.current = sorting;
2230
2224
  const [editing, setEditing] = useState(null);
2231
2225
  const [writeError, setWriteError] = useState(null);
2232
2226
  const stagedEdits = useStagedEdits();
2233
2227
  const [editingCell, setEditingCell] = useState(null);
2234
2228
  const [committing, setCommitting] = useState(false);
2235
- const [liveError, setLiveError] = useState(void 0);
2236
- const [loaded, setLoaded] = useState(null);
2237
- const fetchTables = useCallback(async (shard) => {
2238
- setTablesError(null);
2239
- try {
2240
- const result = await client.query(LIST_TABLES$1, {}, callOptions(shard));
2241
- recordShard(shard);
2242
- setTables(result);
2243
- } catch (error) {
2244
- setTables(null);
2245
- setTablesError(error.message);
2246
- }
2247
- }, [client]);
2248
- const fetchSeqRef = useRef(0);
2249
- const fetchPage = useCallback(async (shard_0, table, nextOffset, searchQuery) => {
2250
- fetchSeqRef.current += 1;
2251
- const seq = fetchSeqRef.current;
2252
- setPageError(null);
2253
- const activeFilters = filtersRef.current;
2254
- const activeSort = sortingRef.current;
2255
- try {
2256
- const result_0 = await client.query(READ_TABLE_PAGE$1, {
2257
- filters: toFilterClauses(activeFilters),
2258
- limit: pageSize,
2259
- offset: nextOffset,
2260
- orderBy: toOrderBy(activeSort),
2261
- search: searchQuery,
2262
- table
2263
- }, callOptions(shard_0));
2264
- if (fetchSeqRef.current !== seq) {
2265
- return;
2266
- }
2267
- setPage(result_0);
2268
- setOffset(nextOffset);
2269
- setLoaded({
2270
- filters: activeFilters,
2271
- offset: nextOffset,
2272
- pageSize,
2273
- search: searchQuery,
2274
- shard: shard_0,
2275
- sort: activeSort,
2276
- table
2277
- });
2278
- } catch (error_0) {
2279
- if (fetchSeqRef.current !== seq) {
2280
- return;
2281
- }
2282
- setPage(null);
2283
- setPageError(error_0.message);
2284
- }
2285
- }, [client, pageSize]);
2229
+ const tablesQuery = useAdminQuery(ADMIN_FUNCTIONS.listTables, NO_ARGS, {
2230
+ live: true,
2231
+ shardKey: debouncedShard
2232
+ });
2233
+ const tables = tablesQuery.data ?? null;
2234
+ const tablesError = tablesQuery.error;
2235
+ const pageArgs = useMemo(() => {
2236
+ return {
2237
+ filters: toFilterClauses(filters),
2238
+ limit: pageSize,
2239
+ offset,
2240
+ orderBy: toOrderBy(sorting),
2241
+ search,
2242
+ table: selectedTable ?? ""
2243
+ };
2244
+ }, [filters, pageSize, offset, sorting, search, selectedTable]);
2245
+ const pageQuery = useAdminQuery(ADMIN_FUNCTIONS.readTablePage, pageArgs, {
2246
+ enabled: selectedTable !== null,
2247
+ keepPreviousData: false,
2248
+ live: true,
2249
+ shardKey: debouncedShard
2250
+ });
2251
+ const page = pageQuery.data ?? null;
2252
+ const pageError = pageQuery.error;
2253
+ const {
2254
+ liveError
2255
+ } = pageQuery;
2286
2256
  useEffect(() => {
2287
- fireAndForget(fetchTables(debouncedShard));
2288
- }, [fetchTables, debouncedShard]);
2289
- useLiveAdmin(ADMIN_FUNCTIONS.readTablePage, {
2290
- filters: toFilterClauses(loaded?.filters ?? []),
2291
- limit: pageSize,
2292
- offset: loaded?.offset ?? 0,
2293
- orderBy: toOrderBy(loaded?.sort ?? []),
2294
- search: loaded?.search ?? "",
2295
- table: loaded?.table ?? ""
2296
- }, loaded?.shard ?? "", (result_1) => {
2297
- setPageError(null);
2298
- setLiveError(void 0);
2299
- setPage(result_1);
2300
- }, loaded !== null, setLiveError);
2301
- useLiveAdmin(ADMIN_FUNCTIONS.listTables, {}, loaded?.shard ?? "", (result_2) => {
2302
- setTablesError(null);
2303
- setLiveError(void 0);
2304
- setTables(result_2);
2305
- }, loaded !== null, setLiveError);
2257
+ if (tablesQuery.data !== void 0) {
2258
+ recordShard(debouncedShard);
2259
+ }
2260
+ }, [tablesQuery.data, debouncedShard]);
2306
2261
  const appliedTableRef = useRef(null);
2307
- const selectTable = useCallback((table_0) => {
2308
- const hydration = hydrationRef.current?.table === void 0 || hydrationRef.current.table === table_0 ? hydrationRef.current : null;
2262
+ const selectTable = useCallback((table) => {
2263
+ const hydration = hydrationRef.current?.table === void 0 || hydrationRef.current.table === table ? hydrationRef.current : null;
2309
2264
  hydrationRef.current = null;
2310
2265
  const nextSorting = fromOrderBy(hydration?.orderBy);
2311
2266
  const nextFilters = toEditableFilters(hydration?.filters ?? []);
@@ -2314,48 +2269,47 @@ const useDataBrowser = ({
2314
2269
  setFilter(nextSearch);
2315
2270
  setFilters(nextFilters);
2316
2271
  filtersRef.current = nextFilters;
2317
- sortingRef.current = nextSorting;
2318
2272
  clearFacets();
2319
2273
  stagedEdits.clear();
2320
2274
  setEditingCell(null);
2321
- setSelectedTable(table_0);
2322
- appliedTableRef.current = table_0;
2323
- fireAndForget(fetchPage(shardKey, table_0, 0, nextSearch));
2324
- onSelectTable?.(table_0);
2325
- }, [clearFacets, fetchPage, onSelectTable, shardKey, stagedEdits]);
2275
+ setOffset(0);
2276
+ setSelectedTable(table);
2277
+ appliedTableRef.current = table;
2278
+ onSelectTable?.(table);
2279
+ }, [clearFacets, onSelectTable, stagedEdits]);
2326
2280
  const navigateToRef = (targetTable, id) => {
2327
2281
  setSorting([]);
2328
2282
  setFilters([]);
2329
2283
  filtersRef.current = [];
2330
2284
  clearFacets();
2285
+ setOffset(0);
2331
2286
  setSelectedTable(targetTable);
2332
2287
  appliedTableRef.current = targetTable;
2333
2288
  setFilter(id);
2334
- fireAndForget(fetchPage(shardKey, targetTable, 0, id));
2335
2289
  onSelectTable?.(targetTable);
2336
2290
  };
2337
2291
  const previewRef = async (targetTable_0, id_0) => {
2338
2292
  try {
2339
- const result_3 = await client.query(READ_TABLE_PAGE$1, {
2293
+ const result = await client.query(READ_TABLE_PAGE$1, {
2340
2294
  filters: [],
2341
2295
  limit: PREVIEW_CANDIDATES,
2342
2296
  offset: 0,
2343
2297
  search: id_0,
2344
2298
  table: targetTable_0
2345
- }, callOptions(shardKey));
2346
- return result_3.rows.find((row) => rowId(row) === id_0) ?? null;
2299
+ }, callOptions(debouncedShard));
2300
+ return result.rows.find((row) => rowId(row) === id_0) ?? null;
2347
2301
  } catch {
2348
2302
  return null;
2349
2303
  }
2350
2304
  };
2351
- const facetFetcher = useCallback((shard_1, table_1, activeFilters_0, searchQuery_0) => (column) => client.query(FACET_COLUMN, {
2305
+ const facetFetcher = useCallback((shard, table_0, activeFilters, searchQuery) => (column) => client.query(FACET_COLUMN, {
2352
2306
  column,
2353
- filters: toFilterClauses(activeFilters_0),
2354
- search: searchQuery_0,
2355
- table: table_1
2356
- }, callOptions(shard_1)), [client]);
2307
+ filters: toFilterClauses(activeFilters),
2308
+ search: searchQuery,
2309
+ table: table_0
2310
+ }, callOptions(shard)), [client]);
2357
2311
  const toggleFacet = (column_0) => {
2358
- toggleFacetColumn(column_0, selectedTable === null ? null : facetFetcher(shardKey, selectedTable, filtersRef.current, search));
2312
+ toggleFacetColumn(column_0, selectedTable === null ? null : facetFetcher(debouncedShard, selectedTable, filtersRef.current, search));
2359
2313
  };
2360
2314
  const facetFilter = (column_1, value) => {
2361
2315
  const text = facetValueText(value);
@@ -2364,24 +2318,25 @@ const useDataBrowser = ({
2364
2318
  operator: "eq",
2365
2319
  value: text
2366
2320
  }]);
2321
+ setOffset(0);
2367
2322
  };
2368
2323
  useEffect(() => {
2369
- if (loaded === null) {
2324
+ if (selectedTable === null) {
2370
2325
  return;
2371
2326
  }
2372
- refetchFacets(facetFetcher(loaded.shard, loaded.table, loaded.filters, loaded.search));
2373
- }, [loaded, facetFetcher, refetchFacets]);
2327
+ refetchFacets(facetFetcher(debouncedShard, selectedTable, filters, search));
2328
+ }, [debouncedShard, selectedTable, filters, search, facetFetcher, refetchFacets]);
2374
2329
  useEffect(() => {
2375
- if (loaded === null || onViewChange === void 0) {
2330
+ if (selectedTable === null || onViewChange === void 0) {
2376
2331
  return;
2377
2332
  }
2378
2333
  onViewChange({
2379
- filters: toFilterClauses(loaded.filters),
2380
- orderBy: toOrderBy(loaded.sort),
2381
- search: loaded.search,
2382
- shard: loaded.shard
2334
+ filters: toFilterClauses(filters),
2335
+ orderBy: toOrderBy(sorting),
2336
+ search,
2337
+ shard: debouncedShard
2383
2338
  });
2384
- }, [loaded, onViewChange]);
2339
+ }, [selectedTable, filters, sorting, search, debouncedShard, onViewChange]);
2385
2340
  useEffect(() => {
2386
2341
  if (tableParam === void 0 || tableParam === "" || tableParam === appliedTableRef.current) {
2387
2342
  return;
@@ -2392,11 +2347,11 @@ const useDataBrowser = ({
2392
2347
  selectTable(target);
2393
2348
  });
2394
2349
  }, [tableParam, selectTable]);
2395
- const goToPage = (nextOffset_0) => {
2350
+ const goToPage = (nextOffset) => {
2396
2351
  if (selectedTable === null) {
2397
2352
  return;
2398
2353
  }
2399
- fireAndForget(fetchPage(shardKey, selectedTable, Math.max(0, nextOffset_0), search));
2354
+ setOffset(Math.max(0, nextOffset));
2400
2355
  };
2401
2356
  const editableColumn = (column_2) => !META_COLUMNS.has(column_2);
2402
2357
  const startCellEdit = (targetRow, column_3) => {
@@ -2421,13 +2376,13 @@ const useDataBrowser = ({
2421
2376
  id: id_1,
2422
2377
  op: "patch",
2423
2378
  table: selectedTable
2424
- }, callOptions(shardKey));
2379
+ }, callOptions(debouncedShard));
2425
2380
  }
2426
2381
  stagedEdits.clear();
2427
2382
  setEditingCell(null);
2428
- await fetchPage(shardKey, selectedTable, offset, search);
2429
- } catch (error_1) {
2430
- setWriteError(error_1.message);
2383
+ pageQuery.refetch();
2384
+ } catch (error) {
2385
+ setWriteError(error.message);
2431
2386
  } finally {
2432
2387
  setCommitting(false);
2433
2388
  }
@@ -2457,30 +2412,6 @@ const useDataBrowser = ({
2457
2412
  }
2458
2413
  return changes;
2459
2414
  }, [page, stagedEdits.staged]);
2460
- useEffect(() => {
2461
- if (selectedTable === null || loaded === null || loaded.search === search) {
2462
- return;
2463
- }
2464
- fireAndForget(fetchPage(shardKey, selectedTable, 0, search));
2465
- }, [search, selectedTable, shardKey, loaded, fetchPage]);
2466
- useEffect(() => {
2467
- if (selectedTable === null || loaded === null || loaded.filters === filters) {
2468
- return;
2469
- }
2470
- fireAndForget(fetchPage(shardKey, selectedTable, 0, search));
2471
- }, [filters, selectedTable, shardKey, loaded, search, fetchPage]);
2472
- useEffect(() => {
2473
- if (selectedTable === null || loaded === null || loaded.sort === sorting) {
2474
- return;
2475
- }
2476
- fireAndForget(fetchPage(shardKey, selectedTable, 0, search));
2477
- }, [sorting, selectedTable, shardKey, loaded, search, fetchPage]);
2478
- useEffect(() => {
2479
- if (selectedTable === null || loaded === null || loaded.pageSize === pageSize) {
2480
- return;
2481
- }
2482
- fireAndForget(fetchPage(shardKey, selectedTable, 0, search));
2483
- }, [pageSize, selectedTable, shardKey, loaded, search, fetchPage]);
2484
2415
  const writeRow = async (op, id_4, documentText) => {
2485
2416
  if (selectedTable === null) {
2486
2417
  return;
@@ -2490,8 +2421,8 @@ const useDataBrowser = ({
2490
2421
  if (op !== "delete") {
2491
2422
  try {
2492
2423
  parsedDocument = documentText === void 0 || documentText.trim() === "" ? {} : JSON.parse(documentText);
2493
- } catch (error_2) {
2494
- setWriteError(`Invalid JSON: ${error_2.message}`);
2424
+ } catch (error_0) {
2425
+ setWriteError(`Invalid JSON: ${error_0.message}`);
2495
2426
  return;
2496
2427
  }
2497
2428
  }
@@ -2501,11 +2432,11 @@ const useDataBrowser = ({
2501
2432
  id: id_4 ?? void 0,
2502
2433
  op,
2503
2434
  table: selectedTable
2504
- }, callOptions(shardKey));
2435
+ }, callOptions(debouncedShard));
2505
2436
  setEditing(null);
2506
- await fetchPage(shardKey, selectedTable, offset, search);
2507
- } catch (error_3) {
2508
- setWriteError(error_3.message);
2437
+ pageQuery.refetch();
2438
+ } catch (error_1) {
2439
+ setWriteError(error_1.message);
2509
2440
  }
2510
2441
  };
2511
2442
  const drainBulk = async (ref, args) => {
@@ -2515,17 +2446,22 @@ const useDataBrowser = ({
2515
2446
  setWriteError(null);
2516
2447
  try {
2517
2448
  for (let batch = 0; batch < MAX_BULK_DELETE_BATCHES; batch += 1) {
2518
- const result_4 = await client.query(ref, args, callOptions(shardKey));
2519
- if (!result_4.hasMore) {
2449
+ const result_0 = await client.query(ref, args, callOptions(debouncedShard));
2450
+ if (!result_0.hasMore) {
2520
2451
  break;
2521
2452
  }
2522
2453
  }
2523
- await fetchPage(shardKey, selectedTable, 0, search);
2524
- } catch (error_4) {
2525
- setWriteError(error_4.message);
2454
+ setOffset(0);
2455
+ pageQuery.refetch();
2456
+ } catch (error_2) {
2457
+ setWriteError(error_2.message);
2526
2458
  }
2527
2459
  };
2528
- const table_2 = useDataBrowserTable(page, sorting, setSorting);
2460
+ const changeSorting = (updater) => {
2461
+ setSorting(updater);
2462
+ setOffset(0);
2463
+ };
2464
+ const table_1 = useDataBrowserTable(page, sorting, changeSorting);
2529
2465
  const currentView = {
2530
2466
  filters: toFilterClauses(filters),
2531
2467
  orderBy: toOrderBy(sorting),
@@ -2539,7 +2475,7 @@ const useDataBrowser = ({
2539
2475
  const rangeStart = page === null || page.rows.length === 0 ? 0 : offset + 1;
2540
2476
  const rangeEnd = page === null ? 0 : offset + page.rows.length;
2541
2477
  const loadTables = () => {
2542
- fireAndForget(fetchTables(shardKey));
2478
+ tablesQuery.refetch();
2543
2479
  };
2544
2480
  const showTable = () => {
2545
2481
  setViewMode("table");
@@ -2561,6 +2497,11 @@ const useDataBrowser = ({
2561
2497
  };
2562
2498
  const onFilterChange = (event) => {
2563
2499
  setFilter(event.target.value);
2500
+ setOffset(0);
2501
+ };
2502
+ const changeFilters = (next) => {
2503
+ setFilters(next);
2504
+ setOffset(0);
2564
2505
  };
2565
2506
  const addRow = () => {
2566
2507
  setWriteError(null);
@@ -2625,11 +2566,11 @@ const useDataBrowser = ({
2625
2566
  id: id_7,
2626
2567
  op: "delete",
2627
2568
  table: selectedTable
2628
- }, callOptions(shardKey));
2569
+ }, callOptions(debouncedShard));
2629
2570
  }
2630
- await fetchPage(shardKey, selectedTable, offset, search);
2631
- } catch (error_5) {
2632
- setWriteError(error_5.message);
2571
+ pageQuery.refetch();
2572
+ } catch (error_3) {
2573
+ setWriteError(error_3.message);
2633
2574
  }
2634
2575
  };
2635
2576
  const onBulkDeleteSelected = (ids_0) => {
@@ -2667,7 +2608,7 @@ const useDataBrowser = ({
2667
2608
  onBulkDeleteSelected,
2668
2609
  onCommitStaged,
2669
2610
  onFilterChange,
2670
- onFiltersChange: setFilters,
2611
+ onFiltersChange: changeFilters,
2671
2612
  onRowDelete,
2672
2613
  onRowEdit,
2673
2614
  page,
@@ -2688,7 +2629,7 @@ const useDataBrowser = ({
2688
2629
  stagedChanges,
2689
2630
  stagedValue: stagedEdits.stagedValue,
2690
2631
  startCellEdit,
2691
- table: table_2,
2632
+ table: table_1,
2692
2633
  tables,
2693
2634
  tablesError,
2694
2635
  toggleFacet,
@@ -2812,23 +2753,20 @@ const useGenerateRows = (onRefresh) => {
2812
2753
  };
2813
2754
  };
2814
2755
 
2815
- const MASK_POLICIES = adminRef(ADMIN_FUNCTIONS.maskPolicies);
2816
2756
  const NO_COLUMNS = [];
2817
2757
  const useMaskPolicies = () => {
2818
- const client = useLunora();
2819
- const [columns, setColumns] = useState(NO_COLUMNS);
2820
- const refresh = async () => {
2821
- try {
2822
- const result = await client.query(MASK_POLICIES, {}, callOptions(""));
2823
- setColumns(Array.isArray(result.columns) ? result.columns : NO_COLUMNS);
2824
- } catch {
2825
- setColumns(NO_COLUMNS);
2826
- }
2827
- };
2828
- useEffect(() => {
2829
- fireAndForget(refresh());
2830
- }, [refresh]);
2831
- return columns;
2758
+ const $ = c(1);
2759
+ let t0;
2760
+ if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
2761
+ t0 = {};
2762
+ $[0] = t0;
2763
+ } else {
2764
+ t0 = $[0];
2765
+ }
2766
+ const {
2767
+ data
2768
+ } = useAdminQuery(ADMIN_FUNCTIONS.maskPolicies, t0);
2769
+ return Array.isArray(data?.columns) ? data.columns : NO_COLUMNS;
2832
2770
  };
2833
2771
 
2834
2772
  const TIMESTAMP_RE$1 = /(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu;
@@ -1,13 +1,14 @@
1
1
  import { useLunora } from '@lunora/react';
2
2
  import { useState } from 'react';
3
- import { ConfirmButton } from './ConfirmButton-WQVUoGFb.js';
4
- import { ShardInput } from './ShardInput-DNCsT1KW.js';
3
+ import { ConfirmButton } from './ConfirmButton-C2eVi2Qv.js';
4
+ import { ShardInput } from './ShardInput-gx_DZXXn.js';
5
5
  import { B as Button } from './button-BhsN2uZH.js';
6
6
  import { C as Card, a as CardContent } from './card-DURq3ElK.js';
7
7
  import { T as Textarea } from './textarea-D3gaCU_-.js';
8
- import { useT } from './createStudioI18n-CgvlmDkN.js';
9
- import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js';
10
- import { f as fireAndForget, c as callOptions, e as errorMessage, a as adminRef } from './internal-BBZYexre.js';
8
+ import { a as useInvalidateAdmin } from './use-admin-query-4JQW2rr1.js';
9
+ import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
10
+ import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-DjXgvJb6.js';
11
+ import { f as fireAndForget, c as callOptions, e as errorMessage, a as adminRef } from './internal-rXJEAhXS.js';
11
12
  import { r as recordShard } from './shard-history-DyebH1R5.js';
12
13
  import { jsxDEV } from 'react/jsx-dev-runtime';
13
14
 
@@ -38,6 +39,7 @@ const ExportImportPanel = ({
38
39
  initialShardKey
39
40
  }) => {
40
41
  const client = useLunora();
42
+ const invalidateAdmin = useInvalidateAdmin();
41
43
  const t = useT();
42
44
  const [shardKey, setShardKey] = useState(initialShardKey ?? "");
43
45
  const [ndjson, setNdjson] = useState("");
@@ -81,6 +83,8 @@ const ExportImportPanel = ({
81
83
  }, callOptions(shardKey));
82
84
  recordShard(shardKey);
83
85
  setImportResult(result_0);
86
+ invalidateAdmin(ADMIN_FUNCTIONS.readTablePage);
87
+ invalidateAdmin(ADMIN_FUNCTIONS.listTables);
84
88
  } catch (error__1) {
85
89
  setError(errorMessage(error__1));
86
90
  } finally {
@@ -1,22 +1,22 @@
1
1
  import { c } from 'react/compiler-runtime';
2
2
  import { useState, useEffect, useMemo, useCallback, useRef } from 'react';
3
- import { ShardInput } from './ShardInput-DNCsT1KW.js';
3
+ import { ShardInput } from './ShardInput-gx_DZXXn.js';
4
4
  import { B as Button } from './button-BhsN2uZH.js';
5
5
  import { E as EmptyState } from './empty-state-DY_oe0k6.js';
6
- import { useT } from './createStudioI18n-CgvlmDkN.js';
7
- import { S as SelectionBar } from './grid-features-DTjG6Sex.js';
6
+ import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
7
+ import { S as SelectionBar } from './grid-features-CzUfqgsM.js';
8
8
  import { C as Card, a as CardContent } from './card-DURq3ElK.js';
9
9
  import { C as Checkbox } from './checkbox-UNkzAxl-.js';
10
10
  import { c as TableHead, a as TableHeader, b as TableRow, d as TableBody, T as Table, e as TableCell } from './table-_RzNvy3R.js';
11
- import { g as formatBytes, f as fireAndForget, e as errorMessage, c as callOptions, a as adminRef } from './internal-BBZYexre.js';
12
- import { ConfirmButton } from './ConfirmButton-WQVUoGFb.js';
11
+ import { d as formatBytes, f as fireAndForget, e as errorMessage, c as callOptions, a as adminRef } from './internal-rXJEAhXS.js';
12
+ import { ConfirmButton } from './ConfirmButton-C2eVi2Qv.js';
13
13
  import { B as Badge } from './badge-B2PKA1-5.js';
14
14
  import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
15
15
  import { I as Input } from './input-XH4r1Pt1.js';
16
- import { d as CLOUDFLARE_R2_URL } from './cf-links-BZfRdxSE.js';
16
+ import { d as CLOUDFLARE_R2_URL } from './cf-links-2cktDedA.js';
17
17
  import { useLunora } from '@lunora/react';
18
18
  import { useAutoRefresh } from './DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js';
19
- import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js';
19
+ import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-DjXgvJb6.js';
20
20
 
21
21
  const useFileItem = (object, prefix, handlers) => {
22
22
  const $ = c(21);
@@ -1,14 +1,14 @@
1
1
  import { useLunora } from '@lunora/react';
2
2
  import { useState, useEffect } from 'react';
3
- import { ShardInput } from './ShardInput-DNCsT1KW.js';
3
+ import { ShardInput } from './ShardInput-gx_DZXXn.js';
4
4
  import { B as Badge } from './badge-B2PKA1-5.js';
5
5
  import { B as Button } from './button-BhsN2uZH.js';
6
6
  import { I as Input } from './input-XH4r1Pt1.js';
7
7
  import { L as Label } from './label-D8ykjn5J.js';
8
8
  import { T as Textarea } from './textarea-D3gaCU_-.js';
9
- import { useT } from './createStudioI18n-CgvlmDkN.js';
10
- import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js';
11
- import { e as errorMessage, d as formatTimestamp, f as fireAndForget, a as adminRef } from './internal-BBZYexre.js';
9
+ import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
10
+ import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-DjXgvJb6.js';
11
+ import { e as errorMessage, b as formatTimestamp, f as fireAndForget, a as adminRef } from './internal-rXJEAhXS.js';
12
12
  import { r as recordShard } from './shard-history-DyebH1R5.js';
13
13
  import { jsxDEV } from 'react/jsx-dev-runtime';
14
14