@malloy-publisher/server 0.0.122 → 0.0.123

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.
@@ -213,35 +213,33 @@ export async function getSchemasForConnection(
213
213
  // Use DuckDB's INFORMATION_SCHEMA.SCHEMATA to list schemas
214
214
  // Use DISTINCT to avoid duplicates from attached databases
215
215
  const result = await malloyConnection.runSQL(
216
- "SELECT DISTINCT schema_name FROM information_schema.schemata ORDER BY schema_name",
216
+ "SELECT DISTINCT schema_name,catalog_name FROM information_schema.schemata ORDER BY catalog_name,schema_name",
217
+ { rowLimit: 1000 },
217
218
  );
218
219
 
219
220
  const rows = standardizeRunSQLResult(result);
220
221
 
221
- // Check if this DuckDB connection has attached databases
222
- const hasAttachedDatabases =
223
- connection.duckdbConnection?.attachedDatabases &&
224
- Array.isArray(connection.duckdbConnection.attachedDatabases) &&
225
- connection.duckdbConnection.attachedDatabases.length > 0;
226
-
227
222
  return rows.map((row: unknown) => {
228
223
  const typedRow = row as Record<string, unknown>;
229
- let schemaName = typedRow.schema_name as string;
230
-
231
- // If we have attached databases and this is not the main schema, prepend the attached database name
232
- if (hasAttachedDatabases && schemaName !== "main") {
233
- const attachedDbName = (
234
- connection.duckdbConnection!.attachedDatabases as Array<{
235
- name: string;
236
- }>
237
- )[0].name;
238
- schemaName = `${attachedDbName}.${schemaName}`;
239
- }
224
+ const schemaName = typedRow.schema_name as string;
225
+ const catalogName = typedRow.catalog_name as string;
240
226
 
241
227
  return {
242
- name: schemaName,
243
- isHidden: false,
244
- isDefault: typedRow.schema_name === "main",
228
+ name: `${catalogName}.${schemaName}`,
229
+ isHidden:
230
+ [
231
+ "information_schema",
232
+ "performance_schema",
233
+ "",
234
+ "SNOWFLAKE",
235
+ "information_schema",
236
+ "pg_catalog",
237
+ "pg_toast",
238
+ ].includes(schemaName as string) ||
239
+ ["md_information_schema", "system"].includes(
240
+ catalogName as string,
241
+ ),
242
+ isDefault: catalogName === "main",
245
243
  };
246
244
  });
247
245
  } catch (error) {
@@ -481,33 +479,11 @@ export async function listTablesForSchema(
481
479
  throw new Error("DuckDB connection is required");
482
480
  }
483
481
  try {
484
- // Check if this DuckDB connection has attached databases and if the schema name is prepended
485
- const hasAttachedDatabases =
486
- connection.duckdbConnection?.attachedDatabases &&
487
- Array.isArray(connection.duckdbConnection.attachedDatabases) &&
488
- connection.duckdbConnection.attachedDatabases.length > 0;
489
-
490
- let actualSchemaName = schemaName;
491
-
492
- // If we have attached databases and the schema name is prepended, extract the actual schema name
493
- if (hasAttachedDatabases && schemaName.includes(".")) {
494
- const attachedDbName = (
495
- connection.duckdbConnection!.attachedDatabases as Array<{
496
- name: string;
497
- }>
498
- )[0].name;
499
- if (schemaName.startsWith(`${attachedDbName}.`)) {
500
- actualSchemaName = schemaName.substring(
501
- attachedDbName.length + 1,
502
- );
503
- }
504
- }
505
-
506
- // Use DuckDB's INFORMATION_SCHEMA.TABLES to list tables in the specified schema
507
- // This follows the DuckDB documentation for listing tables
508
- // For DuckDB, we'll use string interpolation to avoid parameter binding issues
482
+ const catalogName = schemaName.split(".")[0];
483
+ schemaName = schemaName.split(".")[1];
509
484
  const result = await malloyConnection.runSQL(
510
- `SELECT table_name FROM information_schema.tables WHERE table_schema = '${actualSchemaName}' ORDER BY table_name`,
485
+ `SELECT table_name FROM information_schema.tables WHERE table_schema = '${schemaName}' and table_catalog = '${catalogName}' ORDER BY table_name`,
486
+ { rowLimit: 1000 },
511
487
  );
512
488
 
513
489
  const rows = standardizeRunSQLResult(result);
@@ -71,7 +71,10 @@ export class Project {
71
71
 
72
72
  // Reload connections with full config
73
73
  const { malloyConnections, apiConnections } =
74
- await createProjectConnections(payload.connections);
74
+ await createProjectConnections(
75
+ payload.connections,
76
+ this.projectPath,
77
+ );
75
78
 
76
79
  // Update the project's connection maps
77
80
  this.malloyConnections = malloyConnections;
@@ -103,7 +106,7 @@ export class Project {
103
106
 
104
107
  logger.info(`Creating project with connection configuration`);
105
108
  const { malloyConnections, apiConnections } =
106
- await createProjectConnections(connections);
109
+ await createProjectConnections(connections, projectPath);
107
110
 
108
111
  logger.info(
109
112
  `Loaded ${malloyConnections.size + apiConnections.length} connections for project ${projectName}`,
@@ -1,18 +1,18 @@
1
- import { describe, it, expect, beforeAll, afterAll } from "bun:test";
2
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
2
  import {
4
3
  ErrorCode,
5
- Request,
6
4
  Notification,
5
+ Request,
7
6
  Result,
8
7
  } from "@modelcontextprotocol/sdk/types.js";
8
+ import { afterAll, beforeAll, describe, expect, it } from "bun:test";
9
9
  import { URL } from "url";
10
10
 
11
11
  // --- Import E2E Test Setup ---
12
12
  import {
13
+ cleanupE2ETestEnvironment,
13
14
  McpE2ETestEnvironment,
14
15
  setupE2ETestEnvironment,
15
- cleanupE2ETestEnvironment,
16
16
  } from "../../harness/mcp_test_setup";
17
17
 
18
18
  // --- Test Suite ---
@@ -42,7 +42,7 @@ describe("MCP Transport Tests (E2E Integration)", () => {
42
42
  expect(result).toHaveProperty("resources");
43
43
  expect(Array.isArray(result.resources)).toBe(true);
44
44
  },
45
- { timeout: 10000 },
45
+ { timeout: 15000 },
46
46
  );
47
47
 
48
48
  it("should receive InvalidParams error when calling a known method with invalid params", async () => {