@malloy-publisher/server 0.0.198-dev3 → 0.0.198-dev6

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/build.ts CHANGED
@@ -5,14 +5,14 @@ fs.rmSync("./dist", { recursive: true, force: true });
5
5
  fs.mkdirSync("./dist");
6
6
 
7
7
  await build({
8
+ // package_load_worker.ts is bundled as a SEPARATE entrypoint so it
9
+ // can be loaded by `new Worker(...)` at runtime. It must NOT be
10
+ // inlined into server.mjs (workers can't share module state with
11
+ // the parent process — they get their own JS realm).
8
12
  entrypoints: [
9
13
  "./src/server.ts",
10
14
  "./src/instrumentation.ts",
11
- // Schema-introspection worker. Loaded at runtime via
12
- // `new Worker(new URL("./schema_worker.mjs", import.meta.url))`
13
- // from `schema_worker_pool.ts`, so it has to be a separate
14
- // bundle output sitting next to server.mjs in dist/.
15
- "./src/service/schema_worker.ts",
15
+ "./src/package_load/package_load_worker.ts",
16
16
  ],
17
17
  outdir: "./dist",
18
18
  target: "node",
@@ -56,13 +56,27 @@ fs.copyFileSync(
56
56
  // Rename ESM outputs to .mjs so both Node and Bun can execute them
57
57
  fs.renameSync("./dist/server.js", "./dist/server.mjs");
58
58
  fs.renameSync("./dist/instrumentation.js", "./dist/instrumentation.mjs");
59
- // Bun nests outputs by their path relative to the common entrypoint
60
- // root (./src). schema_worker.ts is under src/service/, so its output
61
- // lands at dist/service/schema_worker.js not dist/.
62
- fs.renameSync(
63
- "./dist/service/schema_worker.js",
64
- "./dist/service/schema_worker.mjs",
65
- );
59
+ // Bun emits package_load_worker into its source-relative subdir;
60
+ // flatten so package_load_pool.ts's `resolveWorkerScript()` finds it
61
+ // as a sibling of server.mjs. The path layout match is intentional —
62
+ // keep these two in sync or the worker pool throws at boot (the
63
+ // in-process fallback was removed; missing worker = no service).
64
+ if (fs.existsSync("./dist/package_load/package_load_worker.js")) {
65
+ fs.renameSync(
66
+ "./dist/package_load/package_load_worker.js",
67
+ "./dist/package_load_worker.mjs",
68
+ );
69
+ try {
70
+ fs.rmdirSync("./dist/package_load");
71
+ } catch {
72
+ /* directory may be non-empty if Bun produced sourcemaps; leave it */
73
+ }
74
+ } else if (fs.existsSync("./dist/package_load_worker.js")) {
75
+ fs.renameSync(
76
+ "./dist/package_load_worker.js",
77
+ "./dist/package_load_worker.mjs",
78
+ );
79
+ }
66
80
 
67
81
  // Add shebang to server.mjs for npx/bunx compatibility
68
82
  const serverJsPath = "./dist/server.mjs";
@@ -43,6 +43,7 @@ var __export = (target, all) => {
43
43
  set: __exportSetter.bind(all, name)
44
44
  });
45
45
  };
46
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
46
47
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
47
48
 
48
49
  // ../../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
@@ -115086,40 +115087,7 @@ var require_winston = __commonJS((exports) => {
115086
115087
  warn.forProperties(exports, "deprecated", ["emitErrs", "levelLength"]);
115087
115088
  });
115088
115089
 
115089
- // src/instrumentation.ts
115090
- var import_api = __toESM(require_src(), 1);
115091
- var import_auto_instrumentations_node = __toESM(require_src59(), 1);
115092
- var import_exporter_logs_otlp_proto = __toESM(require_src66(), 1);
115093
- var import_exporter_prometheus = __toESM(require_src71(), 1);
115094
- var import_exporter_trace_otlp_proto = __toESM(require_src72(), 1);
115095
- var import_instrumentation_express = __toESM(require_src17(), 1);
115096
- var import_resources = __toESM(require_src57(), 1);
115097
- var import_sdk_logs = __toESM(require_src75(), 1);
115098
- var import_sdk_node = __toESM(require_src106(), 1);
115099
- var import_sdk_trace_base = __toESM(require_src82(), 1);
115100
- var import_semantic_conventions = __toESM(require_src2(), 1);
115101
- import { monitorEventLoopDelay } from "node:perf_hooks";
115102
-
115103
115090
  // src/logger.ts
115104
- var import_winston = __toESM(require_winston(), 1);
115105
- var isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
115106
- var VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
115107
- var getLogLevel = () => {
115108
- if (process.env.LOG_LEVEL) {
115109
- const logLevel = process.env.LOG_LEVEL.toLowerCase();
115110
- if (VALID_LOG_LEVELS.includes(logLevel)) {
115111
- return logLevel;
115112
- } else {
115113
- console.error(`Invalid log level: ${process.env.LOG_LEVEL}. Valid log levels are: ${VALID_LOG_LEVELS.join(", ")}. Defaulting to "debug".`);
115114
- }
115115
- }
115116
- return "debug";
115117
- };
115118
- var logger = import_winston.default.createLogger({
115119
- level: getLogLevel(),
115120
- format: isTelemetryEnabled ? import_winston.default.format.combine(import_winston.default.format.uncolorize(), import_winston.default.format.timestamp(), import_winston.default.format.errors({ stack: true }), import_winston.default.format.json()) : import_winston.default.format.combine(import_winston.default.format.colorize(), import_winston.default.format.simple()),
115121
- transports: [new import_winston.default.transports.Console]
115122
- });
115123
115091
  function extractTraceIdFromTraceparent(traceparent) {
115124
115092
  if (!traceparent) {
115125
115093
  return;
@@ -115131,7 +115099,6 @@ function extractTraceIdFromTraceparent(traceparent) {
115131
115099
  }
115132
115100
  return;
115133
115101
  }
115134
- var DISABLE_RESPONSE_LOGGING = process.env.DISABLE_RESPONSE_LOGGING === "true" || process.env.DISABLE_RESPONSE_LOGGING === "1";
115135
115102
  function formatDuration(durationMs) {
115136
115103
  if (durationMs >= 1000) {
115137
115104
  const seconds = durationMs / 1000;
@@ -115139,7 +115106,17 @@ function formatDuration(durationMs) {
115139
115106
  }
115140
115107
  return `${durationMs.toFixed(2)}ms`;
115141
115108
  }
115142
- var loggerMiddleware = (req, res, next) => {
115109
+ var import_winston, isTelemetryEnabled, VALID_LOG_LEVELS, getLogLevel = () => {
115110
+ if (process.env.LOG_LEVEL) {
115111
+ const logLevel = process.env.LOG_LEVEL.toLowerCase();
115112
+ if (VALID_LOG_LEVELS.includes(logLevel)) {
115113
+ return logLevel;
115114
+ } else {
115115
+ console.error(`Invalid log level: ${process.env.LOG_LEVEL}. Valid log levels are: ${VALID_LOG_LEVELS.join(", ")}. Defaulting to "debug".`);
115116
+ }
115117
+ }
115118
+ return "debug";
115119
+ }, logger, DISABLE_RESPONSE_LOGGING, loggerMiddleware = (req, res, next) => {
115143
115120
  const startTime = performance.now();
115144
115121
  const resJson = res.json;
115145
115122
  res.json = (body) => {
@@ -115169,8 +115146,7 @@ var loggerMiddleware = (req, res, next) => {
115169
115146
  }
115170
115147
  });
115171
115148
  next();
115172
- };
115173
- var logAxiosError = (error) => {
115149
+ }, logAxiosError = (error) => {
115174
115150
  if (error.response) {
115175
115151
  logger.error("Axios server-side error", {
115176
115152
  url: error.response.config.url,
@@ -115184,8 +115160,32 @@ var logAxiosError = (error) => {
115184
115160
  logger.error("Axios unknown error", { error });
115185
115161
  }
115186
115162
  };
115163
+ var init_logger = __esm(() => {
115164
+ import_winston = __toESM(require_winston(), 1);
115165
+ isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
115166
+ VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
115167
+ logger = import_winston.default.createLogger({
115168
+ level: getLogLevel(),
115169
+ format: isTelemetryEnabled ? import_winston.default.format.combine(import_winston.default.format.uncolorize(), import_winston.default.format.timestamp(), import_winston.default.format.errors({ stack: true }), import_winston.default.format.json()) : import_winston.default.format.combine(import_winston.default.format.colorize(), import_winston.default.format.simple()),
115170
+ transports: [new import_winston.default.transports.Console]
115171
+ });
115172
+ DISABLE_RESPONSE_LOGGING = process.env.DISABLE_RESPONSE_LOGGING === "true" || process.env.DISABLE_RESPONSE_LOGGING === "1";
115173
+ });
115187
115174
 
115188
115175
  // src/instrumentation.ts
115176
+ init_logger();
115177
+ var import_api = __toESM(require_src(), 1);
115178
+ var import_auto_instrumentations_node = __toESM(require_src59(), 1);
115179
+ var import_exporter_logs_otlp_proto = __toESM(require_src66(), 1);
115180
+ var import_exporter_prometheus = __toESM(require_src71(), 1);
115181
+ var import_exporter_trace_otlp_proto = __toESM(require_src72(), 1);
115182
+ var import_instrumentation_express = __toESM(require_src17(), 1);
115183
+ var import_resources = __toESM(require_src57(), 1);
115184
+ var import_sdk_logs = __toESM(require_src75(), 1);
115185
+ var import_sdk_node = __toESM(require_src106(), 1);
115186
+ var import_sdk_trace_base = __toESM(require_src82(), 1);
115187
+ var import_semantic_conventions = __toESM(require_src2(), 1);
115188
+ import { monitorEventLoopDelay } from "node:perf_hooks";
115189
115189
  var prometheusExporter = null;
115190
115190
  var sdk = null;
115191
115191
  function getPrometheusMetricsHandler() {