grain-tools 0.10.15 → 0.10.16

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/mcp-app.html CHANGED
@@ -12728,7 +12728,7 @@ const useAppStore = create$3((set2, get2) => ({
12728
12728
  chartsEnabled: false,
12729
12729
  mcpEnabled: false,
12730
12730
  mcpEntitled: false,
12731
- grainServiceInstalled: true,
12731
+ grainServiceSetup: "registered",
12732
12732
  mcpSafeMode: true,
12733
12733
  activeConnectorType: null,
12734
12734
  activeConnectionId: null,
@@ -12818,7 +12818,7 @@ const useAppStore = create$3((set2, get2) => ({
12818
12818
  "filterResultsByActiveFile",
12819
12819
  "mcpEnabled",
12820
12820
  "mcpEntitled",
12821
- "grainServiceInstalled",
12821
+ "grainServiceSetup",
12822
12822
  "mcpSafeMode",
12823
12823
  "activeConnectorType",
12824
12824
  "activeConnectionId",
@@ -73197,6 +73197,10 @@ const DENSITY_HEIGHTS = {
73197
73197
  normal: { row: 35, header: 42 },
73198
73198
  comfortable: { row: 45, header: 52 }
73199
73199
  };
73200
+ const NUMERIC_TYPE = /^(unsigned\s+|signed\s+)?(u?(tiny|small|medium|big|huge)?int(eger)?\d*|decimal|numeric|number|double|float\d*|real|long|short|byte|money)(\s+(precision|unsigned|signed))?\s*(\(\s*\d+\s*(,\s*\d+\s*)?\))?$/i;
73201
+ function isNumericColumnType(type) {
73202
+ return Boolean(type && NUMERIC_TYPE.test(type.trim()));
73203
+ }
73200
73204
  const DataGrid = reactExports.forwardRef(function DataGrid2({
73201
73205
  theme: theme2,
73202
73206
  data,
@@ -73206,6 +73210,7 @@ const DataGrid = reactExports.forwardRef(function DataGrid2({
73206
73210
  nativeTheme = false,
73207
73211
  disableFilters = false,
73208
73212
  autoSizeStrategy,
73213
+ fillWidth = false,
73209
73214
  onCellDoubleClick
73210
73215
  }, ref) {
73211
73216
  const trackUi = useTrackUi();
@@ -73374,6 +73379,21 @@ const DataGrid = reactExports.forwardRef(function DataGrid2({
73374
73379
  }),
73375
73380
  [data, getNodeValue, copyIncludesHeaders]
73376
73381
  );
73382
+ const userResizedRef = reactExports.useRef(false);
73383
+ const fillSpareWidth = reactExports.useCallback((e2) => {
73384
+ if (userResizedRef.current) return;
73385
+ const body = e2.api.getHorizontalPixelRange?.();
73386
+ const columns = (e2.api.getAllDisplayedColumns?.() ?? []).filter((c) => !c.getPinned());
73387
+ if (!body || columns.length === 0) return;
73388
+ const used = columns.reduce((sum2, c) => sum2 + c.getActualWidth(), 0);
73389
+ if (used < body.right - body.left) e2.api.sizeColumnsToFit();
73390
+ }, []);
73391
+ const noteUserResize = reactExports.useCallback((e2) => {
73392
+ if (e2.source === "uiColumnResized" && e2.finished) userResizedRef.current = true;
73393
+ }, []);
73394
+ reactExports.useEffect(() => {
73395
+ userResizedRef.current = false;
73396
+ }, [data?.columns]);
73377
73397
  const columnDefs = reactExports.useMemo(() => {
73378
73398
  if (!data?.columns) return [];
73379
73399
  const isInRange = (rowIndex, displayedColIndex) => {
@@ -73431,6 +73451,7 @@ const DataGrid = reactExports.forwardRef(function DataGrid2({
73431
73451
  return p2.data[col.name];
73432
73452
  return void 0;
73433
73453
  },
73454
+ ...isNumericColumnType(col.type) ? { cellClass: "sp-num-cell", headerClass: "ag-right-aligned-header" } : {},
73434
73455
  cellClassRules: {
73435
73456
  "sp-range-cell": (p2) => isInRange(p2.rowIndex ?? 0, index + 1)
73436
73457
  },
@@ -73557,6 +73578,11 @@ const DataGrid = reactExports.forwardRef(function DataGrid2({
73557
73578
  onGridReady: (p2) => {
73558
73579
  apiRef.current = p2.api;
73559
73580
  },
73581
+ ...fillWidth ? {
73582
+ onFirstDataRendered: fillSpareWidth,
73583
+ onGridSizeChanged: fillSpareWidth,
73584
+ onColumnResized: noteUserResize
73585
+ } : {},
73560
73586
  rowData: data.rows,
73561
73587
  columnDefs,
73562
73588
  defaultColDef: {
@@ -146829,6 +146855,7 @@ function getFormInitialData(connection) {
146829
146855
  delete formData["type"];
146830
146856
  delete formData["builtIn"];
146831
146857
  delete formData["hasPassword"];
146858
+ delete formData["draft"];
146832
146859
  return formData;
146833
146860
  }
146834
146861
  function schemaHasPasswordField(schema) {
@@ -146867,9 +146894,10 @@ function schemaForConnectionMode(schema, connectorId, mode) {
146867
146894
  }
146868
146895
  };
146869
146896
  }
146897
+ const UNREACHABLE_MESSAGE = "Can't reach Grain. Start Grain and try again.";
146870
146898
  const ConnectionsManager = ({ initialAdd = false, onSubpageChange }) => {
146871
146899
  const { callServerTool, isReady, mode, sendMessage, onMessage } = useHostContext();
146872
- const grainServiceInstalled = useAppStore((state) => state.grainServiceInstalled);
146900
+ const grainServiceSetup = useAppStore((state) => state.grainServiceSetup);
146873
146901
  const supportsActiveConnection = mode === "vscode";
146874
146902
  const trackUi = useTrackUi();
146875
146903
  reactExports.useEffect(() => {
@@ -147101,7 +147129,8 @@ const ConnectionsManager = ({ initialAdd = false, onSubpageChange }) => {
147101
147129
  const profileToSave = {
147102
147130
  ...formData,
147103
147131
  type: typeToSave,
147104
- id: connection?.id ?? `conn_${Date.now()}`
147132
+ id: connection?.id ?? `conn_${Date.now()}`,
147133
+ ...connection?.draft ? { draft: false } : {}
147105
147134
  };
147106
147135
  if (isEditing2 && profileToSave["password"] === "") {
147107
147136
  delete profileToSave["password"];
@@ -147377,10 +147406,30 @@ const ConnectionsManager = ({ initialAdd = false, onSubpageChange }) => {
147377
147406
  }
147378
147407
  return null;
147379
147408
  };
147409
+ const renderUnreachableActions = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { marginTop: 12, display: "flex", gap: 8 }, children: [
147410
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "sp-btn", onClick: fetchData, children: "Retry" }),
147411
+ mode === "vscode" && /* @__PURE__ */ jsxRuntimeExports.jsx(
147412
+ "button",
147413
+ {
147414
+ className: "sp-btn",
147415
+ onClick: () => sendMessage?.(grainServiceSetup === "not-set-up" ? "setUpGrain" : "startGrain"),
147416
+ children: grainServiceSetup === "not-set-up" ? "Set up Grain" : "Start Grain"
147417
+ }
147418
+ )
147419
+ ] });
147420
+ const renderUnreachableState = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sp-conn-empty", children: [
147421
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: UNREACHABLE_MESSAGE }),
147422
+ renderUnreachableActions()
147423
+ ] });
147380
147424
  const renderConnectionForm = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sp-detail", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sp-conn-detail-body", children: [
147381
147425
  renderToast(),
147382
- !selectedType && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sp-conn-form-section", children: "Database Type" }),
147383
- !selectedType && ["local", "server"].map((group) => {
147426
+ !selectedType && connectors.length === 0 && connectionsUnreachable && renderUnreachableState(),
147427
+ !selectedType && connectors.length === 0 && !connectionsUnreachable && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sp-conn-empty", children: [
147428
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "No database types are available." }),
147429
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "sp-btn", onClick: fetchData, children: "Retry" }) })
147430
+ ] }),
147431
+ !selectedType && connectors.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sp-conn-form-section", children: "Database Type" }),
147432
+ !selectedType && connectors.length > 0 && ["local", "server"].map((group) => {
147384
147433
  const groupConnectors = connectors.filter((c) => getConnectorGroup(c.id) === group);
147385
147434
  if (groupConnectors.length === 0) {
147386
147435
  return null;
@@ -147557,11 +147606,8 @@ const ConnectionsManager = ({ initialAdd = false, onSubpageChange }) => {
147557
147606
  gap: "12px"
147558
147607
  },
147559
147608
  children: connections.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sp-conn-empty", style: { gridColumn: "1 / -1" }, children: [
147560
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: connectionsUnreachable ? "Can't reach Grain. Start Grain and try again." : "No connections configured." }),
147561
- connectionsUnreachable && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { marginTop: 12, display: "flex", gap: 8 }, children: [
147562
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "sp-btn", onClick: fetchData, children: "Retry" }),
147563
- mode === "vscode" && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "sp-btn", onClick: () => sendMessage?.("startGrain"), children: grainServiceInstalled ? "Start Grain" : "Set up Grain" })
147564
- ] }),
147609
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: connectionsUnreachable ? UNREACHABLE_MESSAGE : "No connections configured." }),
147610
+ connectionsUnreachable && renderUnreachableActions(),
147565
147611
  mode === "vscode" && !connectionsUnreachable && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: 12 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
147566
147612
  "button",
147567
147613
  {
@@ -147638,7 +147684,8 @@ const ConnectionsManager = ({ initialAdd = false, onSubpageChange }) => {
147638
147684
  },
147639
147685
  children: [
147640
147686
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `sp-dot sp-dot-${status}` }),
147641
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "var(--sp-muted-fg)" }, children: statusLabel }),
147687
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { color: "var(--sp-muted-fg)" }, children: c.draft ? "Needs setup" : statusLabel }),
147688
+ c.draft && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-pill", children: "Draft" }),
147642
147689
  isActive && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-pill", style: { marginLeft: "auto" }, children: "Active" })
147643
147690
  ]
147644
147691
  }
@@ -147662,7 +147709,8 @@ const ConnectionsManager = ({ initialAdd = false, onSubpageChange }) => {
147662
147709
  meta: selectedConnection && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
147663
147710
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-conn-type-badge", children: selectedConnection.type }),
147664
147711
  supportsActiveConnection && activeConnectionId === selectedConnection.id && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-conn-active-badge", children: "Active" }),
147665
- selectedConnection.builtIn && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-conn-built-in-label", children: "Built-in" })
147712
+ selectedConnection.builtIn && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-conn-built-in-label", children: "Built-in" }),
147713
+ selectedConnection.draft && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sp-conn-built-in-label", children: "Draft" })
147666
147714
  ] }),
147667
147715
  actions: isFormOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", onClick: closeForm, "aria-label": "Cancel", children: "Cancel" }) : selectedConnection && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
147668
147716
  supportsActiveConnection && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -172062,6 +172110,12 @@ body.vscode-high-contrast .ag-theme-quartz {
172062
172110
  outline: none !important;
172063
172111
  }
172064
172112
 
172113
+ .sp-num-cell {
172114
+ justify-content: flex-end;
172115
+ text-align: right;
172116
+ font-variant-numeric: tabular-nums;
172117
+ }
172118
+
172065
172119
  .sp-null {
172066
172120
  color: var(--sp-muted-fg);
172067
172121
  font-style: italic;