@malloy-publisher/sdk 0.0.125 → 0.0.126

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/sdk",
3
3
  "description": "Malloy Publisher SDK",
4
- "version": "0.0.125",
4
+ "version": "0.0.126",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -14,9 +14,10 @@ import {
14
14
  TableContainer,
15
15
  TableHead,
16
16
  TableRow,
17
+ TextField,
17
18
  Typography,
18
19
  } from "@mui/material";
19
- import React from "react";
20
+ import React, { useState } from "react";
20
21
  import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
21
22
  import { parseResourceUri } from "../../utils/formatting";
22
23
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
@@ -224,6 +225,7 @@ function TablesInSchema({
224
225
  }: TablesInSchemaProps) {
225
226
  const { projectName: projectName } = parseResourceUri(resourceUri);
226
227
  const { apiClients } = useServer();
228
+ const [searchTerm, setSearchTerm] = useState("");
227
229
  const { data, isSuccess, isError, error, isLoading } = useQueryWithApiError({
228
230
  queryKey: ["tablesInSchema", projectName, connectionName, schemaName],
229
231
  queryFn: () =>
@@ -234,12 +236,38 @@ function TablesInSchema({
234
236
  ),
235
237
  });
236
238
 
239
+ const filteredTables =
240
+ isSuccess && data?.data
241
+ ? data.data
242
+ .filter((table: { resource: string }) => {
243
+ const tableName =
244
+ table.resource.split(".").pop()?.toLowerCase() || "";
245
+ return tableName.includes(searchTerm.toLowerCase());
246
+ })
247
+ .sort((a: { resource: string }, b: { resource: string }) => {
248
+ const tableNameA = a.resource.split(".").pop() || a.resource;
249
+ const tableNameB = b.resource.split(".").pop() || b.resource;
250
+ return tableNameA.localeCompare(tableNameB);
251
+ })
252
+ : [];
253
+
237
254
  return (
238
255
  <>
239
256
  <Typography variant="overline" fontWeight="bold">
240
257
  Tables in {schemaName}
241
258
  </Typography>
242
259
  <Divider />
260
+ <Box sx={{ mt: 1, mb: 1 }}>
261
+ <TextField
262
+ size="small"
263
+ fullWidth
264
+ placeholder="Search tables..."
265
+ value={searchTerm}
266
+ onChange={(e) => setSearchTerm(e.target.value)}
267
+ variant="outlined"
268
+ />
269
+ </Box>
270
+ <Divider />
243
271
  <Box sx={{ mt: "2px", maxHeight: "600px", overflowY: "auto" }}>
244
272
  {isLoading && <Loading text="Fetching Tables..." />}
245
273
  {isError && (
@@ -248,43 +276,32 @@ function TablesInSchema({
248
276
  context={`${projectName} > ${connectionName} > ${schemaName}`}
249
277
  />
250
278
  )}
251
- {isSuccess && data?.data?.length === 0 && (
279
+ {isSuccess && filteredTables.length === 0 && (
252
280
  <Typography variant="body2">No Tables</Typography>
253
281
  )}
254
282
  {isSuccess && data?.data && data.data.length > 0 && (
255
283
  <List dense disablePadding>
256
- {data.data
257
- .sort(
258
- (a: { resource: string }, b: { resource: string }) => {
259
- // Extract table names for sorting
260
- const tableNameA =
261
- a.resource.split(".").pop() || a.resource;
262
- const tableNameB =
263
- b.resource.split(".").pop() || b.resource;
264
- return tableNameA.localeCompare(tableNameB);
265
- },
266
- )
267
- .map(
268
- (table: {
269
- resource: string;
270
- columns: Array<{ name: string; type: string }>;
271
- }) => {
272
- // Extract table name from resource path (e.g., "schema.table_name" -> "table_name")
273
- const tableName =
274
- table.resource.split(".").pop() || table.resource;
275
- return (
276
- <ListItemButton
277
- key={table.resource}
278
- onClick={() => onTableClick(table)}
279
- >
280
- <ListItemText
281
- primary={tableName}
282
- secondary={`${table.columns.length} columns`}
283
- />
284
- </ListItemButton>
285
- );
286
- },
287
- )}
284
+ {filteredTables.map(
285
+ (table: {
286
+ resource: string;
287
+ columns: Array<{ name: string; type: string }>;
288
+ }) => {
289
+ // Extract table name from resource path (e.g., "schema.table_name" -> "table_name")
290
+ const tableName =
291
+ table.resource.split(".").pop() || table.resource;
292
+ return (
293
+ <ListItemButton
294
+ key={table.resource}
295
+ onClick={() => onTableClick(table)}
296
+ >
297
+ <ListItemText
298
+ primary={tableName}
299
+ secondary={`${table.columns.length} columns`}
300
+ />
301
+ </ListItemButton>
302
+ );
303
+ },
304
+ )}
288
305
  </List>
289
306
  )}
290
307
  </Box>
@@ -5,6 +5,7 @@ import { PackageContainer } from "../styles";
5
5
  import About from "./About";
6
6
  import AddPackageDialog from "./AddPackageDialog";
7
7
  import Packages from "./Packages";
8
+ import { useEffect } from "react";
8
9
 
9
10
  interface ProjectProps {
10
11
  onSelectPackage: (to: string, event?: React.MouseEvent) => void;
@@ -17,6 +18,11 @@ export default function Project({
17
18
  }: ProjectProps) {
18
19
  const { mutable } = useServer();
19
20
  const { projectName } = parseResourceUri(resourceUri);
21
+
22
+ useEffect(() => {
23
+ window.scrollTo({ top: 0, behavior: "auto" });
24
+ }, []);
25
+
20
26
  return (
21
27
  <>
22
28
  <PackageContainer>
@@ -56,7 +56,7 @@ const getApiClients = (
56
56
 
57
57
  axiosInstance.interceptors.request.use(async (config) => {
58
58
  const token = await accessToken?.();
59
- config.headers.Authorization = token ? `Bearer ${token}` : "";
59
+ config.headers.Authorization = token || "";
60
60
  return config;
61
61
  });
62
62