@lunora/studio 1.0.0-alpha.2 → 1.0.0-alpha.21
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/__assets__/package-og.svg +1 -1
- package/dist/index.d.ts +23 -17
- package/dist/index.js +34 -34
- package/dist/mount.d.ts +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_shared/{ADMIN_FUNCTION_PREFIX-DmBqMZ-z.js → ADMIN_FUNCTIONS-CdaxLGkE.js} +3 -0
- package/dist/packem_shared/{ApiDocsPanel-DpRjJhG5.js → ApiDocsPanel-BgrN4kml.js} +3 -3
- package/dist/packem_shared/{ApiReferencePanel-DMIUp-kK.js → ApiReferencePanel-1vubqG5s.js} +2 -2
- package/dist/packem_shared/{ApiTab-DURGU15e.js → ApiTab-CHkX49o_.js} +4 -4
- package/dist/packem_shared/{AuditPanel-BC59Nhst.js → AuditPanel-CP9HM9nq.js} +19 -31
- package/dist/packem_shared/{CommandPalette-Dx_CoB9i.js → CommandPalette-BtgkBzZI.js} +2 -2
- package/dist/packem_shared/{ConfirmButton-WQVUoGFb.js → ConfirmButton-C2eVi2Qv.js} +1 -1
- package/dist/packem_shared/{ConnectionBadge-Bxagrip8.js → ConnectionBadge-B2DDM2Tn.js} +1 -1
- package/dist/packem_shared/{createStudioI18n-CgvlmDkN.js → DEFAULT_LOCALE-CiX4W7Kr.js} +1 -1
- package/dist/packem_shared/{DataBrowser-Coz6jJE6.js → DataBrowser-Bb1gTQ6c.js} +182 -249
- package/dist/packem_shared/{ExportImportPanel-WO34fJxy.js → ExportImportPanel-Dj87tRa5.js} +9 -5
- package/dist/packem_shared/{FileBrowser-Zcr-Qgxo.js → FileBrowser-CWvxp_is.js} +7 -7
- package/dist/packem_shared/{FunctionRunner-j0Rd5m9t.js → FunctionRunner-DlWApMCH.js} +4 -4
- package/dist/packem_shared/{FunctionStatsPanel-DboBl-XL.js → FunctionStatsPanel-CuO2Tmw-.js} +141 -198
- package/dist/packem_shared/{GlobalDataBrowser-9MhPEfgN.js → GlobalDataBrowser-3X9uRfdO.js} +37 -66
- package/dist/packem_shared/{HealthPanel-DOIgbUtx.js → HealthPanel-Dj0GRo5P.js} +31 -23
- package/dist/packem_shared/{HomePanel-bdOCNA-p.js → HomePanel-BewOCuag.js} +450 -389
- package/dist/packem_shared/{InsightsPanel-DaZPnSgt.js → InsightsPanel-y_Q-xdPY.js} +104 -66
- package/dist/packem_shared/{LogsPanel-CWdqAGpQ.js → LogsPanel-C7crgYoS.js} +35 -47
- package/dist/packem_shared/{MailPanel-D_EGtDnS.js → MailPanel-PILidruz.js} +31 -38
- package/dist/packem_shared/{MetricsPanel-E4Gv6wTO.js → MetricsPanel-DioILzgf.js} +34 -48
- package/dist/packem_shared/{MigrationsPanel-DQdPY9io.js → MigrationsPanel-DkIcRoE5.js} +31 -38
- package/dist/packem_shared/{OpenRpcReferencePanel-j2p3HB0s.js → OpenRpcReferencePanel-vbcYbv3V.js} +2 -2
- package/dist/packem_shared/{PitrPanel-BbBkQR6t.js → PitrPanel-yKJ1JPPk.js} +4 -4
- package/dist/packem_shared/{ScheduledJobs-Ok1CYYwI.js → ScheduledJobs-BWNwIN3I.js} +164 -61
- package/dist/packem_shared/{SchemaViewer-D8XGnp-X.js → SchemaViewer-CNr8Wame.js} +4 -4
- package/dist/packem_shared/{SecurityAdvisorPanel-Cdm2IxLW.js → SecurityAdvisorPanel-BBzv7L3c.js} +44 -31
- package/dist/packem_shared/SettingsPanel-BKSKl8tl.js +390 -0
- package/dist/packem_shared/{ShardInput-DNCsT1KW.js → ShardInput-gx_DZXXn.js} +1 -1
- package/dist/packem_shared/SqlEditorPanel-CkemCQvy.js +13 -0
- package/dist/packem_shared/Studio-QkOjc2NS.js +33 -0
- package/dist/packem_shared/{StudioApp-dvywkJ8I.js → StudioApp-TEElspKL.js} +278 -4
- package/dist/packem_shared/{StudioI18nProvider-Dcajsznk.js → StudioI18nProvider-B-tDCZIi.js} +1 -1
- package/dist/packem_shared/TableEditor-JS3sXYgS.js +11 -0
- package/dist/packem_shared/{advisor-view-DBlzJi6C.js → advisor-view-CGcfMiPq.js} +1 -1
- package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-Cnij4Zp5.d.ts} +1 -1
- package/dist/packem_shared/{cf-links-BZfRdxSE.js → cf-links-2cktDedA.js} +1 -1
- package/dist/packem_shared/{data-grid-CCh2Couo.js → data-grid-B5CaV3wS.js} +2 -2
- package/dist/packem_shared/{grid-features-DTjG6Sex.js → grid-features-CzUfqgsM.js} +3 -3
- package/dist/packem_shared/{internal-BBZYexre.js → internal-rXJEAhXS.js} +1 -1
- package/dist/packem_shared/{live-status-bPff1O7Y.js → live-status-FZ0psC1z.js} +1 -1
- package/dist/packem_shared/{reference-view-BCKIoai7.js → reference-view-B4E49Lip.js} +3 -3
- package/dist/packem_shared/{sql-editor-panel-CW2y2x9h.js → sql-editor-panel-CUJoYF1Z.js} +6 -6
- package/dist/packem_shared/{studio-BDVd7rIV.js → studio-c5Vf7kSh.js} +2897 -1668
- package/dist/packem_shared/{TableEditor-DIVDk3vT.js → table-editor-9fhJ4hMJ.js} +43 -7
- package/dist/packem_shared/{table-list-sidebar-aZHLq70w.js → table-list-sidebar-Bg7uzbvC.js} +2 -2
- package/dist/packem_shared/use-admin-query-BkbdNFNz.js +105 -0
- package/dist/standalone/studio.js +198 -176
- package/dist/styles.css +1 -1
- package/package.json +13 -12
- package/dist/packem_shared/SettingsPanel-D3WF2mBU.js +0 -176
- package/dist/packem_shared/SqlEditorPanel-BuQ7f2Hs.js +0 -13
- package/dist/packem_shared/Studio-D36od9Oz.js +0 -33
- package/dist/packem_shared/use-live-admin-D1h1Fzsd.js +0 -73
- 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-
|
|
5
|
-
import { ShardInput } from './ShardInput-
|
|
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 './
|
|
8
|
-
import { ADMIN_FUNCTIONS } from './
|
|
9
|
-
import { h as formatCell, f as fireAndForget, c as callOptions, a as adminRef,
|
|
7
|
+
import { useT } from './DEFAULT_LOCALE-CiX4W7Kr.js';
|
|
8
|
+
import { ADMIN_FUNCTIONS } from './ADMIN_FUNCTIONS-CdaxLGkE.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-
|
|
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-
|
|
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-
|
|
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-BkbdNFNz.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;
|
|
@@ -1564,7 +1564,7 @@ const useDataBrowserTable = (page, sorting, onSortingChange) => {
|
|
|
1564
1564
|
};
|
|
1565
1565
|
});
|
|
1566
1566
|
}, [columns, references]);
|
|
1567
|
-
const data = rows ?? [];
|
|
1567
|
+
const data = useMemo(() => rows ?? [], [rows]);
|
|
1568
1568
|
const [rowSelection, setRowSelection] = useState({});
|
|
1569
1569
|
const [columnVisibility, setColumnVisibility] = useState({});
|
|
1570
1570
|
const table = useReactTable({
|
|
@@ -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__"];
|
|
@@ -2199,18 +2199,8 @@ const useDataBrowser = ({
|
|
|
2199
2199
|
const client = useLunora();
|
|
2200
2200
|
const [pageSize, setPageSize] = useState(initialPageSize);
|
|
2201
2201
|
const [shardKey, setShardKey] = useState(initialShardKey ?? "");
|
|
2202
|
-
const
|
|
2203
|
-
filters: initialFilters,
|
|
2204
|
-
orderBy: initialOrderBy,
|
|
2205
|
-
search: initialSearch,
|
|
2206
|
-
table: tableParam
|
|
2207
|
-
});
|
|
2208
|
-
const [tables, setTables] = useState(null);
|
|
2209
|
-
const [tablesError, setTablesError] = useState(null);
|
|
2210
|
-
const [selectedTable, setSelectedTable] = useState(null);
|
|
2202
|
+
const selectedTable = tableParam === void 0 || tableParam === "" ? null : tableParam;
|
|
2211
2203
|
const [offset, setOffset] = useState(0);
|
|
2212
|
-
const [page, setPage] = useState(null);
|
|
2213
|
-
const [pageError, setPageError] = useState(null);
|
|
2214
2204
|
const [viewMode, setViewMode] = useState("table");
|
|
2215
2205
|
const [sorting, setSorting] = useState(() => fromOrderBy(initialOrderBy));
|
|
2216
2206
|
const [filter, setFilter] = useState(initialSearch ?? "");
|
|
@@ -2225,183 +2215,143 @@ const useDataBrowser = ({
|
|
|
2225
2215
|
refetchFacets,
|
|
2226
2216
|
toggleFacet: toggleFacetColumn
|
|
2227
2217
|
} = useFacets();
|
|
2228
|
-
const sortingRef = useRef(sorting);
|
|
2229
|
-
sortingRef.current = sorting;
|
|
2230
2218
|
const [editing, setEditing] = useState(null);
|
|
2231
2219
|
const [writeError, setWriteError] = useState(null);
|
|
2232
2220
|
const stagedEdits = useStagedEdits();
|
|
2233
2221
|
const [editingCell, setEditingCell] = useState(null);
|
|
2234
2222
|
const [committing, setCommitting] = useState(false);
|
|
2235
|
-
const
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
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]);
|
|
2223
|
+
const tablesQuery = useAdminQuery(ADMIN_FUNCTIONS.listTables, NO_ARGS, {
|
|
2224
|
+
live: true,
|
|
2225
|
+
shardKey: debouncedShard
|
|
2226
|
+
});
|
|
2227
|
+
const tables = tablesQuery.data ?? null;
|
|
2228
|
+
const tablesError = tablesQuery.error;
|
|
2229
|
+
const pageArgs = useMemo(() => {
|
|
2230
|
+
return {
|
|
2231
|
+
filters: toFilterClauses(filters),
|
|
2232
|
+
limit: pageSize,
|
|
2233
|
+
offset,
|
|
2234
|
+
orderBy: toOrderBy(sorting),
|
|
2235
|
+
search,
|
|
2236
|
+
table: selectedTable ?? ""
|
|
2237
|
+
};
|
|
2238
|
+
}, [filters, pageSize, offset, sorting, search, selectedTable]);
|
|
2239
|
+
const pageQuery = useAdminQuery(ADMIN_FUNCTIONS.readTablePage, pageArgs, {
|
|
2240
|
+
enabled: selectedTable !== null,
|
|
2241
|
+
keepPreviousData: false,
|
|
2242
|
+
live: true,
|
|
2243
|
+
shardKey: debouncedShard
|
|
2244
|
+
});
|
|
2245
|
+
const page = pageQuery.data ?? null;
|
|
2246
|
+
const pageError = pageQuery.error;
|
|
2247
|
+
const {
|
|
2248
|
+
liveError
|
|
2249
|
+
} = pageQuery;
|
|
2286
2250
|
useEffect(() => {
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
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);
|
|
2306
|
-
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;
|
|
2309
|
-
hydrationRef.current = null;
|
|
2310
|
-
const nextSorting = fromOrderBy(hydration?.orderBy);
|
|
2311
|
-
const nextFilters = toEditableFilters(hydration?.filters ?? []);
|
|
2312
|
-
const nextSearch = hydration?.search ?? "";
|
|
2313
|
-
setSorting(nextSorting);
|
|
2314
|
-
setFilter(nextSearch);
|
|
2315
|
-
setFilters(nextFilters);
|
|
2316
|
-
filtersRef.current = nextFilters;
|
|
2317
|
-
sortingRef.current = nextSorting;
|
|
2318
|
-
clearFacets();
|
|
2319
|
-
stagedEdits.clear();
|
|
2320
|
-
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]);
|
|
2251
|
+
if (tablesQuery.data !== void 0) {
|
|
2252
|
+
recordShard(debouncedShard);
|
|
2253
|
+
}
|
|
2254
|
+
}, [tablesQuery.data, debouncedShard]);
|
|
2255
|
+
const selectTable = useCallback((table2) => {
|
|
2256
|
+
onSelectTable?.(table2);
|
|
2257
|
+
}, [onSelectTable]);
|
|
2326
2258
|
const navigateToRef = (targetTable, id) => {
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
clearFacets();
|
|
2331
|
-
setSelectedTable(targetTable);
|
|
2332
|
-
appliedTableRef.current = targetTable;
|
|
2333
|
-
setFilter(id);
|
|
2334
|
-
fireAndForget(fetchPage(shardKey, targetTable, 0, id));
|
|
2335
|
-
onSelectTable?.(targetTable);
|
|
2259
|
+
onSelectTable?.(targetTable, {
|
|
2260
|
+
search: id
|
|
2261
|
+
});
|
|
2336
2262
|
};
|
|
2337
|
-
const previewRef = async (
|
|
2263
|
+
const previewRef = async (targetTable, id) => {
|
|
2338
2264
|
try {
|
|
2339
|
-
const
|
|
2265
|
+
const result = await client.query(READ_TABLE_PAGE$1, {
|
|
2340
2266
|
filters: [],
|
|
2341
2267
|
limit: PREVIEW_CANDIDATES,
|
|
2342
2268
|
offset: 0,
|
|
2343
|
-
search:
|
|
2344
|
-
table:
|
|
2345
|
-
}, callOptions(
|
|
2346
|
-
return
|
|
2269
|
+
search: id,
|
|
2270
|
+
table: targetTable
|
|
2271
|
+
}, callOptions(debouncedShard));
|
|
2272
|
+
return result.rows.find((row) => rowId(row) === id) ?? null;
|
|
2347
2273
|
} catch {
|
|
2348
2274
|
return null;
|
|
2349
2275
|
}
|
|
2350
2276
|
};
|
|
2351
|
-
const facetFetcher = useCallback((
|
|
2277
|
+
const facetFetcher = useCallback((shard, table2, activeFilters, searchQuery) => (column) => client.query(FACET_COLUMN, {
|
|
2352
2278
|
column,
|
|
2353
|
-
filters: toFilterClauses(
|
|
2354
|
-
search:
|
|
2355
|
-
table:
|
|
2356
|
-
}, callOptions(
|
|
2357
|
-
const toggleFacet = (
|
|
2358
|
-
toggleFacetColumn(
|
|
2279
|
+
filters: toFilterClauses(activeFilters),
|
|
2280
|
+
search: searchQuery,
|
|
2281
|
+
table: table2
|
|
2282
|
+
}, callOptions(shard)), [client]);
|
|
2283
|
+
const toggleFacet = (column) => {
|
|
2284
|
+
toggleFacetColumn(column, selectedTable === null ? null : facetFetcher(debouncedShard, selectedTable, filtersRef.current, search));
|
|
2359
2285
|
};
|
|
2360
|
-
const facetFilter = (
|
|
2286
|
+
const facetFilter = (column, value) => {
|
|
2361
2287
|
const text = facetValueText(value);
|
|
2362
|
-
setFilters((current) => [...current.filter((clause) => clause.column !==
|
|
2363
|
-
column
|
|
2288
|
+
setFilters((current) => [...current.filter((clause) => clause.column !== column), {
|
|
2289
|
+
column,
|
|
2364
2290
|
operator: "eq",
|
|
2365
2291
|
value: text
|
|
2366
2292
|
}]);
|
|
2293
|
+
setOffset(0);
|
|
2367
2294
|
};
|
|
2295
|
+
const facetFetcherRef = useRef(facetFetcher);
|
|
2296
|
+
const refetchFacetsRef = useRef(refetchFacets);
|
|
2297
|
+
const onViewChangeRef = useRef(onViewChange);
|
|
2298
|
+
facetFetcherRef.current = facetFetcher;
|
|
2299
|
+
refetchFacetsRef.current = refetchFacets;
|
|
2300
|
+
onViewChangeRef.current = onViewChange;
|
|
2368
2301
|
useEffect(() => {
|
|
2369
|
-
if (
|
|
2302
|
+
if (selectedTable === null) {
|
|
2370
2303
|
return;
|
|
2371
2304
|
}
|
|
2372
|
-
|
|
2373
|
-
}, [
|
|
2305
|
+
refetchFacetsRef.current(facetFetcherRef.current(debouncedShard, selectedTable, filters, search));
|
|
2306
|
+
}, [debouncedShard, selectedTable, filters, search]);
|
|
2307
|
+
const seededTableRef = useRef(tableParam);
|
|
2374
2308
|
useEffect(() => {
|
|
2375
|
-
if (
|
|
2309
|
+
if (selectedTable === null || onViewChangeRef.current === void 0 || seededTableRef.current !== tableParam) {
|
|
2376
2310
|
return;
|
|
2377
2311
|
}
|
|
2378
|
-
|
|
2379
|
-
filters: toFilterClauses(
|
|
2380
|
-
orderBy: toOrderBy(
|
|
2381
|
-
search
|
|
2382
|
-
shard:
|
|
2312
|
+
onViewChangeRef.current({
|
|
2313
|
+
filters: toFilterClauses(filters),
|
|
2314
|
+
orderBy: toOrderBy(sorting),
|
|
2315
|
+
search,
|
|
2316
|
+
shard: debouncedShard
|
|
2383
2317
|
});
|
|
2384
|
-
}, [
|
|
2318
|
+
}, [selectedTable, tableParam, filters, sorting, search, debouncedShard]);
|
|
2319
|
+
const initialFiltersRef = useRef(initialFilters);
|
|
2320
|
+
const initialOrderByRef = useRef(initialOrderBy);
|
|
2321
|
+
const initialSearchRef = useRef(initialSearch);
|
|
2322
|
+
const initialShardKeyRef = useRef(initialShardKey);
|
|
2323
|
+
initialFiltersRef.current = initialFilters;
|
|
2324
|
+
initialOrderByRef.current = initialOrderBy;
|
|
2325
|
+
initialSearchRef.current = initialSearch;
|
|
2326
|
+
initialShardKeyRef.current = initialShardKey;
|
|
2385
2327
|
useEffect(() => {
|
|
2386
|
-
if (
|
|
2328
|
+
if (seededTableRef.current === tableParam) {
|
|
2387
2329
|
return;
|
|
2388
2330
|
}
|
|
2389
|
-
|
|
2390
|
-
const target = tableParam;
|
|
2331
|
+
seededTableRef.current = tableParam;
|
|
2391
2332
|
queueMicrotask(() => {
|
|
2392
|
-
|
|
2333
|
+
const nextFilters = toEditableFilters(initialFiltersRef.current ?? []);
|
|
2334
|
+
setSorting(fromOrderBy(initialOrderByRef.current));
|
|
2335
|
+
setFilter(initialSearchRef.current ?? "");
|
|
2336
|
+
setFilters(nextFilters);
|
|
2337
|
+
filtersRef.current = nextFilters;
|
|
2338
|
+
setShardKey(initialShardKeyRef.current ?? "");
|
|
2339
|
+
clearFacets();
|
|
2340
|
+
stagedEdits.clear();
|
|
2341
|
+
setEditingCell(null);
|
|
2342
|
+
setOffset(0);
|
|
2393
2343
|
});
|
|
2394
|
-
}, [tableParam
|
|
2395
|
-
const goToPage = (
|
|
2344
|
+
}, [tableParam]);
|
|
2345
|
+
const goToPage = (nextOffset) => {
|
|
2396
2346
|
if (selectedTable === null) {
|
|
2397
2347
|
return;
|
|
2398
2348
|
}
|
|
2399
|
-
|
|
2349
|
+
setOffset(Math.max(0, nextOffset));
|
|
2400
2350
|
};
|
|
2401
|
-
const editableColumn = (
|
|
2402
|
-
const startCellEdit = (targetRow,
|
|
2351
|
+
const editableColumn = (column) => !META_COLUMNS.has(column);
|
|
2352
|
+
const startCellEdit = (targetRow, column) => {
|
|
2403
2353
|
setEditingCell({
|
|
2404
|
-
column
|
|
2354
|
+
column,
|
|
2405
2355
|
rowId: targetRow
|
|
2406
2356
|
});
|
|
2407
2357
|
};
|
|
@@ -2415,19 +2365,19 @@ const useDataBrowser = ({
|
|
|
2415
2365
|
setWriteError(null);
|
|
2416
2366
|
setCommitting(true);
|
|
2417
2367
|
try {
|
|
2418
|
-
for (const [
|
|
2368
|
+
for (const [id, columns] of Object.entries(stagedEdits.staged)) {
|
|
2419
2369
|
await client.query(WRITE_ROW$1, {
|
|
2420
2370
|
doc: columns,
|
|
2421
|
-
id
|
|
2371
|
+
id,
|
|
2422
2372
|
op: "patch",
|
|
2423
2373
|
table: selectedTable
|
|
2424
|
-
}, callOptions(
|
|
2374
|
+
}, callOptions(debouncedShard));
|
|
2425
2375
|
}
|
|
2426
2376
|
stagedEdits.clear();
|
|
2427
2377
|
setEditingCell(null);
|
|
2428
|
-
|
|
2429
|
-
} catch (
|
|
2430
|
-
setWriteError(
|
|
2378
|
+
pageQuery.refetch();
|
|
2379
|
+
} catch (error) {
|
|
2380
|
+
setWriteError(error.message);
|
|
2431
2381
|
} finally {
|
|
2432
2382
|
setCommitting(false);
|
|
2433
2383
|
}
|
|
@@ -2438,50 +2388,26 @@ const useDataBrowser = ({
|
|
|
2438
2388
|
};
|
|
2439
2389
|
const stagedChanges = useMemo(() => {
|
|
2440
2390
|
const rowsById = /* @__PURE__ */ new Map();
|
|
2441
|
-
for (const
|
|
2442
|
-
const
|
|
2443
|
-
if (
|
|
2444
|
-
rowsById.set(
|
|
2391
|
+
for (const row of page?.rows ?? []) {
|
|
2392
|
+
const id = rowId(row);
|
|
2393
|
+
if (id !== null) {
|
|
2394
|
+
rowsById.set(id, row);
|
|
2445
2395
|
}
|
|
2446
2396
|
}
|
|
2447
2397
|
const changes = [];
|
|
2448
|
-
for (const [
|
|
2449
|
-
for (const [
|
|
2398
|
+
for (const [id, columns] of Object.entries(stagedEdits.staged)) {
|
|
2399
|
+
for (const [column, newValue] of Object.entries(columns)) {
|
|
2450
2400
|
changes.push({
|
|
2451
|
-
column
|
|
2401
|
+
column,
|
|
2452
2402
|
newValue,
|
|
2453
|
-
oldValue: rowsById.get(
|
|
2454
|
-
rowId:
|
|
2403
|
+
oldValue: rowsById.get(id)?.[column],
|
|
2404
|
+
rowId: id
|
|
2455
2405
|
});
|
|
2456
2406
|
}
|
|
2457
2407
|
}
|
|
2458
2408
|
return changes;
|
|
2459
2409
|
}, [page, stagedEdits.staged]);
|
|
2460
|
-
|
|
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
|
-
const writeRow = async (op, id_4, documentText) => {
|
|
2410
|
+
const writeRow = async (op, id, documentText) => {
|
|
2485
2411
|
if (selectedTable === null) {
|
|
2486
2412
|
return;
|
|
2487
2413
|
}
|
|
@@ -2490,22 +2416,22 @@ const useDataBrowser = ({
|
|
|
2490
2416
|
if (op !== "delete") {
|
|
2491
2417
|
try {
|
|
2492
2418
|
parsedDocument = documentText === void 0 || documentText.trim() === "" ? {} : JSON.parse(documentText);
|
|
2493
|
-
} catch (
|
|
2494
|
-
setWriteError(`Invalid JSON: ${
|
|
2419
|
+
} catch (error) {
|
|
2420
|
+
setWriteError(`Invalid JSON: ${error.message}`);
|
|
2495
2421
|
return;
|
|
2496
2422
|
}
|
|
2497
2423
|
}
|
|
2498
2424
|
try {
|
|
2499
2425
|
await client.query(WRITE_ROW$1, {
|
|
2500
2426
|
doc: parsedDocument,
|
|
2501
|
-
id:
|
|
2427
|
+
id: id ?? void 0,
|
|
2502
2428
|
op,
|
|
2503
2429
|
table: selectedTable
|
|
2504
|
-
}, callOptions(
|
|
2430
|
+
}, callOptions(debouncedShard));
|
|
2505
2431
|
setEditing(null);
|
|
2506
|
-
|
|
2507
|
-
} catch (
|
|
2508
|
-
setWriteError(
|
|
2432
|
+
pageQuery.refetch();
|
|
2433
|
+
} catch (error) {
|
|
2434
|
+
setWriteError(error.message);
|
|
2509
2435
|
}
|
|
2510
2436
|
};
|
|
2511
2437
|
const drainBulk = async (ref, args) => {
|
|
@@ -2515,17 +2441,22 @@ const useDataBrowser = ({
|
|
|
2515
2441
|
setWriteError(null);
|
|
2516
2442
|
try {
|
|
2517
2443
|
for (let batch = 0; batch < MAX_BULK_DELETE_BATCHES; batch += 1) {
|
|
2518
|
-
const
|
|
2519
|
-
if (!
|
|
2444
|
+
const result = await client.query(ref, args, callOptions(debouncedShard));
|
|
2445
|
+
if (!result.hasMore) {
|
|
2520
2446
|
break;
|
|
2521
2447
|
}
|
|
2522
2448
|
}
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2449
|
+
setOffset(0);
|
|
2450
|
+
pageQuery.refetch();
|
|
2451
|
+
} catch (error) {
|
|
2452
|
+
setWriteError(error.message);
|
|
2526
2453
|
}
|
|
2527
2454
|
};
|
|
2528
|
-
const
|
|
2455
|
+
const changeSorting = (updater) => {
|
|
2456
|
+
setSorting(updater);
|
|
2457
|
+
setOffset(0);
|
|
2458
|
+
};
|
|
2459
|
+
const table = useDataBrowserTable(page, sorting, changeSorting);
|
|
2529
2460
|
const currentView = {
|
|
2530
2461
|
filters: toFilterClauses(filters),
|
|
2531
2462
|
orderBy: toOrderBy(sorting),
|
|
@@ -2539,7 +2470,7 @@ const useDataBrowser = ({
|
|
|
2539
2470
|
const rangeStart = page === null || page.rows.length === 0 ? 0 : offset + 1;
|
|
2540
2471
|
const rangeEnd = page === null ? 0 : offset + page.rows.length;
|
|
2541
2472
|
const loadTables = () => {
|
|
2542
|
-
|
|
2473
|
+
tablesQuery.refetch();
|
|
2543
2474
|
};
|
|
2544
2475
|
const showTable = () => {
|
|
2545
2476
|
setViewMode("table");
|
|
@@ -2561,13 +2492,18 @@ const useDataBrowser = ({
|
|
|
2561
2492
|
};
|
|
2562
2493
|
const onFilterChange = (event) => {
|
|
2563
2494
|
setFilter(event.target.value);
|
|
2495
|
+
setOffset(0);
|
|
2496
|
+
};
|
|
2497
|
+
const changeFilters = (next) => {
|
|
2498
|
+
setFilters(next);
|
|
2499
|
+
setOffset(0);
|
|
2564
2500
|
};
|
|
2565
2501
|
const addRow = () => {
|
|
2566
2502
|
setWriteError(null);
|
|
2567
2503
|
const seed = {};
|
|
2568
|
-
for (const
|
|
2569
|
-
if (!META_COLUMNS.has(
|
|
2570
|
-
seed[
|
|
2504
|
+
for (const column of page?.columns ?? []) {
|
|
2505
|
+
if (!META_COLUMNS.has(column)) {
|
|
2506
|
+
seed[column] = "";
|
|
2571
2507
|
}
|
|
2572
2508
|
}
|
|
2573
2509
|
setEditing({
|
|
@@ -2575,10 +2511,10 @@ const useDataBrowser = ({
|
|
|
2575
2511
|
id: ""
|
|
2576
2512
|
});
|
|
2577
2513
|
};
|
|
2578
|
-
const setEditorDocumentText = (
|
|
2579
|
-
setEditing((
|
|
2580
|
-
docText:
|
|
2581
|
-
id:
|
|
2514
|
+
const setEditorDocumentText = (text) => {
|
|
2515
|
+
setEditing((current) => current === null ? current : {
|
|
2516
|
+
docText: text,
|
|
2517
|
+
id: current.id
|
|
2582
2518
|
});
|
|
2583
2519
|
};
|
|
2584
2520
|
const saveEdit = () => {
|
|
@@ -2604,15 +2540,15 @@ const useDataBrowser = ({
|
|
|
2604
2540
|
setPageSize(size);
|
|
2605
2541
|
setOffset(0);
|
|
2606
2542
|
};
|
|
2607
|
-
const onRowEdit = (
|
|
2543
|
+
const onRowEdit = (id, original) => {
|
|
2608
2544
|
setWriteError(null);
|
|
2609
2545
|
setEditing({
|
|
2610
2546
|
docText: JSON.stringify(rowDocument(original), null, 2),
|
|
2611
|
-
id
|
|
2547
|
+
id
|
|
2612
2548
|
});
|
|
2613
2549
|
};
|
|
2614
|
-
const onRowDelete = (
|
|
2615
|
-
fireAndForget(writeRow("delete",
|
|
2550
|
+
const onRowDelete = (id) => {
|
|
2551
|
+
fireAndForget(writeRow("delete", id));
|
|
2616
2552
|
};
|
|
2617
2553
|
const deleteSelected = async (ids) => {
|
|
2618
2554
|
if (selectedTable === null || ids.length === 0) {
|
|
@@ -2620,20 +2556,20 @@ const useDataBrowser = ({
|
|
|
2620
2556
|
}
|
|
2621
2557
|
setWriteError(null);
|
|
2622
2558
|
try {
|
|
2623
|
-
for (const
|
|
2559
|
+
for (const id of ids) {
|
|
2624
2560
|
await client.query(WRITE_ROW$1, {
|
|
2625
|
-
id
|
|
2561
|
+
id,
|
|
2626
2562
|
op: "delete",
|
|
2627
2563
|
table: selectedTable
|
|
2628
|
-
}, callOptions(
|
|
2564
|
+
}, callOptions(debouncedShard));
|
|
2629
2565
|
}
|
|
2630
|
-
|
|
2631
|
-
} catch (
|
|
2632
|
-
setWriteError(
|
|
2566
|
+
pageQuery.refetch();
|
|
2567
|
+
} catch (error) {
|
|
2568
|
+
setWriteError(error.message);
|
|
2633
2569
|
}
|
|
2634
2570
|
};
|
|
2635
|
-
const onBulkDeleteSelected = (
|
|
2636
|
-
fireAndForget(deleteSelected(
|
|
2571
|
+
const onBulkDeleteSelected = (ids) => {
|
|
2572
|
+
fireAndForget(deleteSelected(ids));
|
|
2637
2573
|
};
|
|
2638
2574
|
const onCommitStaged = () => {
|
|
2639
2575
|
fireAndForget(commitStaged());
|
|
@@ -2667,7 +2603,7 @@ const useDataBrowser = ({
|
|
|
2667
2603
|
onBulkDeleteSelected,
|
|
2668
2604
|
onCommitStaged,
|
|
2669
2605
|
onFilterChange,
|
|
2670
|
-
onFiltersChange:
|
|
2606
|
+
onFiltersChange: changeFilters,
|
|
2671
2607
|
onRowDelete,
|
|
2672
2608
|
onRowEdit,
|
|
2673
2609
|
page,
|
|
@@ -2688,7 +2624,7 @@ const useDataBrowser = ({
|
|
|
2688
2624
|
stagedChanges,
|
|
2689
2625
|
stagedValue: stagedEdits.stagedValue,
|
|
2690
2626
|
startCellEdit,
|
|
2691
|
-
table
|
|
2627
|
+
table,
|
|
2692
2628
|
tables,
|
|
2693
2629
|
tablesError,
|
|
2694
2630
|
toggleFacet,
|
|
@@ -2812,23 +2748,20 @@ const useGenerateRows = (onRefresh) => {
|
|
|
2812
2748
|
};
|
|
2813
2749
|
};
|
|
2814
2750
|
|
|
2815
|
-
const MASK_POLICIES = adminRef(ADMIN_FUNCTIONS.maskPolicies);
|
|
2816
2751
|
const NO_COLUMNS = [];
|
|
2817
2752
|
const useMaskPolicies = () => {
|
|
2818
|
-
const
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
}, [refresh]);
|
|
2831
|
-
return columns;
|
|
2753
|
+
const $ = c(1);
|
|
2754
|
+
let t0;
|
|
2755
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
2756
|
+
t0 = {};
|
|
2757
|
+
$[0] = t0;
|
|
2758
|
+
} else {
|
|
2759
|
+
t0 = $[0];
|
|
2760
|
+
}
|
|
2761
|
+
const {
|
|
2762
|
+
data
|
|
2763
|
+
} = useAdminQuery(ADMIN_FUNCTIONS.maskPolicies, t0);
|
|
2764
|
+
return Array.isArray(data?.columns) ? data.columns : NO_COLUMNS;
|
|
2832
2765
|
};
|
|
2833
2766
|
|
|
2834
2767
|
const TIMESTAMP_RE$1 = /(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu;
|