@malloy-publisher/server 0.0.190 → 0.0.191

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@malloy-publisher/server",
3
3
  "description": "Malloy Publisher Server",
4
- "version": "0.0.190",
5
- "main": "dist/server.js",
4
+ "version": "0.0.191",
5
+ "main": "dist/server.mjs",
6
6
  "bin": {
7
- "malloy-publisher": "dist/server.js"
7
+ "malloy-publisher": "dist/server.mjs"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
@@ -19,11 +19,11 @@
19
19
  "test:integration": "bun test --timeout 100000 tests",
20
20
  "build": "bun generate-api-types && bun build:app && NODE_ENV=production bun run build.ts",
21
21
  "build:server-only": "bun generate-api-types && NODE_ENV=production bun run build.ts",
22
- "start": "NODE_ENV=production node ./dist/server.js",
23
- "start:init": "NODE_ENV=production node ./dist/server.js --init",
22
+ "start": "NODE_ENV=production bun run ./dist/server.mjs",
23
+ "start:init": "NODE_ENV=production bun run ./dist/server.mjs --init",
24
24
  "start:dev": "NODE_ENV=development bun --watch src/server.ts",
25
25
  "start:dev:init": "NODE_ENV=development bun --watch src/server.ts --init",
26
- "start:instrumented": "node --require ./dist/instrumentation.js ./dist/server.js",
26
+ "start:instrumented": "bun --preload ./dist/instrumentation.mjs ./dist/server.mjs",
27
27
  "lint": "bunx eslint \"./src/**/*.ts\"",
28
28
  "format": "bunx prettier --write '**/*.{ts,tsx}'",
29
29
  "build:app": "cd ../app && NODE_ENV=production bunx vite build",
@@ -1,4 +1,4 @@
1
- import * as Handlebars from "handlebars";
1
+ import Handlebars from "handlebars";
2
2
  import { z } from "zod";
3
3
  import {
4
4
  PromptMessageSchema,
package/src/server.ts CHANGED
@@ -6,13 +6,14 @@ import {
6
6
  } from "./instrumentation";
7
7
 
8
8
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
9
- import * as bodyParser from "body-parser";
9
+ import bodyParser from "body-parser";
10
10
  import cors from "cors";
11
11
  import express from "express";
12
12
  import * as http from "http";
13
13
  import { createProxyMiddleware } from "http-proxy-middleware";
14
14
  import { AddressInfo } from "net";
15
15
  import * as path from "path";
16
+ import { fileURLToPath } from "url";
16
17
  import { CompileController } from "./controller/compile.controller";
17
18
  import { ConnectionController } from "./controller/connection.controller";
18
19
  import { DatabaseController } from "./controller/database.controller";
@@ -120,15 +121,10 @@ const SHUTDOWN_DRAIN_DURATION_SECONDS = Number(
120
121
  const SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS = Number(
121
122
  process.env.SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS || 0,
122
123
  );
123
- // Find the app directory - handle NPX vs local execution
124
- let ROOT: string;
125
- if (require.main) {
126
- // Use the main module's directory (works for NPX and direct execution)
127
- ROOT = path.join(path.dirname(require.main.filename), "app");
128
- } else {
129
- // Fallback to current script directory
130
- ROOT = path.join(path.dirname(process.argv[1] || __filename), "app");
131
- }
124
+ // Find the app directory relative to this bundled server file.
125
+ // Works under both ESM (import.meta.url) and when invoked via NPX.
126
+ const __filename_esm = fileURLToPath(import.meta.url);
127
+ const ROOT = path.join(path.dirname(__filename_esm), "app");
132
128
  const SERVER_ROOT = path.resolve(process.cwd(), process.env.SERVER_ROOT || ".");
133
129
  const API_PREFIX = "/api/v0";
134
130
  const isDevelopment = process.env["NODE_ENV"] === "development";
@@ -22,7 +22,7 @@ import {
22
22
  MalloySQLParser,
23
23
  MalloySQLStatementType,
24
24
  } from "@malloydata/malloy-sql";
25
- import malloyPackage from "@malloydata/malloy/package.json";
25
+ import { createRequire } from "module";
26
26
  import { DataStyles } from "@malloydata/render";
27
27
  import { metrics } from "@opentelemetry/api";
28
28
  import * as fs from "fs/promises";
@@ -45,9 +45,9 @@ import { BuildManifest } from "../storage/DatabaseInterface";
45
45
  import { URL_READER } from "../utils";
46
46
  import {
47
47
  buildFilterClause,
48
+ FilterValidationError,
48
49
  injectFilterRefinement,
49
50
  parseFilters,
50
- FilterValidationError,
51
51
  type FilterDefinition,
52
52
  type FilterParams,
53
53
  } from "./filter";
@@ -65,7 +65,11 @@ export type PostgresConnection = components["schemas"]["PostgresConnection"];
65
65
  export type BigqueryConnection = components["schemas"]["BigqueryConnection"];
66
66
  export type TrinoConnection = components["schemas"]["TrinoConnection"];
67
67
 
68
- const MALLOY_VERSION = malloyPackage.version;
68
+ const MALLOY_VERSION = (
69
+ createRequire(import.meta.url)("@malloydata/malloy/package.json") as {
70
+ version: string;
71
+ }
72
+ ).version;
69
73
 
70
74
  export type ModelType = "model" | "notebook";
71
75
 
@@ -1,5 +1,5 @@
1
1
  import { Mutex } from "async-mutex";
2
- import * as duckdb from "duckdb";
2
+ import duckdb from "duckdb";
3
3
  import * as path from "path";
4
4
  import { DatabaseConnection } from "../DatabaseInterface";
5
5
 
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "target": "ESNext", // Specifies the JavaScript version to target when transpiling code.
4
4
  "lib": ["ESNext", "DOM", "DOM.Iterable"], // Specifies the libraries available for the code.
5
- "module": "CommonJS", // Defines the module system to use for code generation.
5
+ "module": "ESNext", // Emits ESM syntax; Bun bundler handles final module format.
6
6
  "skipLibCheck": true, // Skips type checking of declaration files.
7
7
  "useDefineForClassFields": true, // Enables the use of 'define' for class fields.
8
8
  "experimentalDecorators": true,