@malloy-publisher/server 0.0.198-dev2 → 0.0.198-dev4
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 +22 -12
- package/dist/compile_worker.mjs +633 -0
- package/dist/instrumentation.mjs +36 -57
- package/dist/server.mjs +986 -650
- package/package.json +1 -1
- package/src/compile/compile_pool.spec.ts +292 -0
- package/src/compile/compile_pool.ts +796 -0
- package/src/compile/compile_worker.ts +721 -0
- package/src/compile/protocol.ts +270 -0
- package/src/health.ts +13 -0
- package/src/instrumentation.ts +0 -50
- package/src/server.ts +0 -5
- package/src/service/environment_store.ts +0 -9
- package/src/service/model.ts +226 -3
- package/src/service/model_worker_path.spec.ts +133 -0
- package/src/service/package.spec.ts +7 -11
- package/src/service/package.ts +156 -49
- package/dist/service/schema_worker.mjs +0 -61
- package/src/service/process_stats_reporter.ts +0 -169
- package/src/service/schema_worker.ts +0 -123
- package/src/service/schema_worker_pool.ts +0 -278
- package/tests/integration/concurrent_environment/concurrent_environment.integration.spec.ts +0 -235
package/dist/server.mjs
CHANGED
|
@@ -44,6 +44,7 @@ var __export = (target, all) => {
|
|
|
44
44
|
set: __exportSetter.bind(all, name)
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
48
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
48
49
|
|
|
49
50
|
// ../../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
@@ -115087,6 +115088,91 @@ var require_winston = __commonJS((exports) => {
|
|
|
115087
115088
|
warn.forProperties(exports, "deprecated", ["emitErrs", "levelLength"]);
|
|
115088
115089
|
});
|
|
115089
115090
|
|
|
115091
|
+
// src/logger.ts
|
|
115092
|
+
function extractTraceIdFromTraceparent(traceparent) {
|
|
115093
|
+
if (!traceparent) {
|
|
115094
|
+
return;
|
|
115095
|
+
}
|
|
115096
|
+
const parts = traceparent.split("-");
|
|
115097
|
+
const traceId = parts.length >= 2 ? parts[1] : parts.length == 1 ? parts[0] : undefined;
|
|
115098
|
+
if (traceId && traceId.length === 32 && /^[0-9a-fA-F]{32}$/.test(traceId)) {
|
|
115099
|
+
return traceId;
|
|
115100
|
+
}
|
|
115101
|
+
return;
|
|
115102
|
+
}
|
|
115103
|
+
function formatDuration(durationMs) {
|
|
115104
|
+
if (durationMs >= 1000) {
|
|
115105
|
+
const seconds = durationMs / 1000;
|
|
115106
|
+
return `${seconds.toFixed(2)}s`;
|
|
115107
|
+
}
|
|
115108
|
+
return `${durationMs.toFixed(2)}ms`;
|
|
115109
|
+
}
|
|
115110
|
+
var import_winston, isTelemetryEnabled, VALID_LOG_LEVELS, getLogLevel = () => {
|
|
115111
|
+
if (process.env.LOG_LEVEL) {
|
|
115112
|
+
const logLevel = process.env.LOG_LEVEL.toLowerCase();
|
|
115113
|
+
if (VALID_LOG_LEVELS.includes(logLevel)) {
|
|
115114
|
+
return logLevel;
|
|
115115
|
+
} else {
|
|
115116
|
+
console.error(`Invalid log level: ${process.env.LOG_LEVEL}. Valid log levels are: ${VALID_LOG_LEVELS.join(", ")}. Defaulting to "debug".`);
|
|
115117
|
+
}
|
|
115118
|
+
}
|
|
115119
|
+
return "debug";
|
|
115120
|
+
}, logger, DISABLE_RESPONSE_LOGGING, loggerMiddleware = (req, res, next) => {
|
|
115121
|
+
const startTime = performance.now();
|
|
115122
|
+
const resJson = res.json;
|
|
115123
|
+
res.json = (body) => {
|
|
115124
|
+
res.locals.body = body;
|
|
115125
|
+
return resJson.call(res, body);
|
|
115126
|
+
};
|
|
115127
|
+
res.on("finish", () => {
|
|
115128
|
+
const endTime = performance.now();
|
|
115129
|
+
const durationMs = endTime - startTime;
|
|
115130
|
+
const traceparent = req.headers["traceparent"];
|
|
115131
|
+
const traceId = extractTraceIdFromTraceparent(traceparent);
|
|
115132
|
+
const logMetadata = {
|
|
115133
|
+
statusCode: res.statusCode,
|
|
115134
|
+
duration: formatDuration(durationMs),
|
|
115135
|
+
payload: req.body,
|
|
115136
|
+
params: req.params,
|
|
115137
|
+
query: req.query
|
|
115138
|
+
};
|
|
115139
|
+
if (!DISABLE_RESPONSE_LOGGING) {
|
|
115140
|
+
logMetadata.response = res.locals.body;
|
|
115141
|
+
}
|
|
115142
|
+
if (traceId) {
|
|
115143
|
+
logMetadata.traceId = traceId;
|
|
115144
|
+
}
|
|
115145
|
+
if (req.url !== "/metrics" && req.url !== "/health" && req.url !== "/health/liveness" && req.url !== "/health/readiness") {
|
|
115146
|
+
logger.info(`${req.method} ${req.url}`, logMetadata);
|
|
115147
|
+
}
|
|
115148
|
+
});
|
|
115149
|
+
next();
|
|
115150
|
+
}, logAxiosError = (error) => {
|
|
115151
|
+
if (error.response) {
|
|
115152
|
+
logger.error("Axios server-side error", {
|
|
115153
|
+
url: error.response.config.url,
|
|
115154
|
+
status: error.response.status,
|
|
115155
|
+
headers: error.response.headers,
|
|
115156
|
+
data: error.response.data
|
|
115157
|
+
});
|
|
115158
|
+
} else if (error.request) {
|
|
115159
|
+
logger.error("Axios client-side error", { error: error.request });
|
|
115160
|
+
} else {
|
|
115161
|
+
logger.error("Axios unknown error", { error });
|
|
115162
|
+
}
|
|
115163
|
+
};
|
|
115164
|
+
var init_logger = __esm(() => {
|
|
115165
|
+
import_winston = __toESM(require_winston(), 1);
|
|
115166
|
+
isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
|
|
115167
|
+
VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
|
|
115168
|
+
logger = import_winston.default.createLogger({
|
|
115169
|
+
level: getLogLevel(),
|
|
115170
|
+
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()),
|
|
115171
|
+
transports: [new import_winston.default.transports.Console]
|
|
115172
|
+
});
|
|
115173
|
+
DISABLE_RESPONSE_LOGGING = process.env.DISABLE_RESPONSE_LOGGING === "true" || process.env.DISABLE_RESPONSE_LOGGING === "1";
|
|
115174
|
+
});
|
|
115175
|
+
|
|
115090
115176
|
// ../../node_modules/bytes/index.js
|
|
115091
115177
|
var require_bytes = __commonJS((exports, module) => {
|
|
115092
115178
|
/*!
|
|
@@ -147228,6 +147314,132 @@ var require_dist4 = __commonJS((exports) => {
|
|
|
147228
147314
|
__exportStar(require_legacy2(), exports);
|
|
147229
147315
|
});
|
|
147230
147316
|
|
|
147317
|
+
// src/constants.ts
|
|
147318
|
+
import os from "os";
|
|
147319
|
+
var API_PREFIX = "/api/v0", README_NAME = "README.md", PUBLISHER_CONFIG_NAME = "publisher.config.json", PACKAGE_MANIFEST_NAME = "publisher.json", MODEL_FILE_SUFFIX = ".malloy", NOTEBOOK_FILE_SUFFIX = ".malloynb", ROW_LIMIT = 1000, TEMP_DIR_PATH, PUBLISHER_DATA_DIR = "publisher_data";
|
|
147320
|
+
var init_constants = __esm(() => {
|
|
147321
|
+
TEMP_DIR_PATH = os.tmpdir();
|
|
147322
|
+
});
|
|
147323
|
+
|
|
147324
|
+
// src/errors.ts
|
|
147325
|
+
import { MalloyError } from "@malloydata/malloy";
|
|
147326
|
+
function internalErrorToHttpError(error) {
|
|
147327
|
+
if (error instanceof BadRequestError) {
|
|
147328
|
+
return httpError(400, error.message);
|
|
147329
|
+
} else if (error instanceof FrozenConfigError) {
|
|
147330
|
+
return httpError(403, error.message);
|
|
147331
|
+
} else if (error instanceof EnvironmentNotFoundError) {
|
|
147332
|
+
return httpError(404, error.message);
|
|
147333
|
+
} else if (error instanceof PackageNotFoundError) {
|
|
147334
|
+
return httpError(404, error.message);
|
|
147335
|
+
} else if (error instanceof ModelNotFoundError) {
|
|
147336
|
+
return httpError(404, error.message);
|
|
147337
|
+
} else if (error instanceof MalloyError) {
|
|
147338
|
+
return httpError(400, error.message);
|
|
147339
|
+
} else if (error instanceof ConnectionNotFoundError) {
|
|
147340
|
+
return httpError(404, error.message);
|
|
147341
|
+
} else if (error instanceof ConnectionAuthError) {
|
|
147342
|
+
return httpError(422, error.message);
|
|
147343
|
+
} else if (error instanceof ModelCompilationError) {
|
|
147344
|
+
return httpError(424, error.message);
|
|
147345
|
+
} else if (error instanceof ConnectionError) {
|
|
147346
|
+
return httpError(502, error.message);
|
|
147347
|
+
} else if (error instanceof MaterializationNotFoundError) {
|
|
147348
|
+
return httpError(404, error.message);
|
|
147349
|
+
} else if (error instanceof MaterializationConflictError) {
|
|
147350
|
+
return httpError(409, error.message);
|
|
147351
|
+
} else if (error instanceof InvalidStateTransitionError) {
|
|
147352
|
+
return httpError(409, error.message);
|
|
147353
|
+
} else if (error instanceof ServiceUnavailableError) {
|
|
147354
|
+
return httpError(503, error.message);
|
|
147355
|
+
} else {
|
|
147356
|
+
return httpError(500, error.message);
|
|
147357
|
+
}
|
|
147358
|
+
}
|
|
147359
|
+
function httpError(code, message) {
|
|
147360
|
+
return {
|
|
147361
|
+
status: code,
|
|
147362
|
+
json: {
|
|
147363
|
+
code,
|
|
147364
|
+
message
|
|
147365
|
+
}
|
|
147366
|
+
};
|
|
147367
|
+
}
|
|
147368
|
+
var NotImplementedError, BadRequestError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, ConnectionNotFoundError, ConnectionError, ConnectionAuthError, ModelCompilationError, FrozenConfigError, MaterializationNotFoundError, MaterializationConflictError, InvalidStateTransitionError, ServiceUnavailableError;
|
|
147369
|
+
var init_errors = __esm(() => {
|
|
147370
|
+
init_constants();
|
|
147371
|
+
NotImplementedError = class NotImplementedError extends Error {
|
|
147372
|
+
constructor(message) {
|
|
147373
|
+
super(message);
|
|
147374
|
+
}
|
|
147375
|
+
};
|
|
147376
|
+
BadRequestError = class BadRequestError extends Error {
|
|
147377
|
+
constructor(message) {
|
|
147378
|
+
super(message);
|
|
147379
|
+
}
|
|
147380
|
+
};
|
|
147381
|
+
EnvironmentNotFoundError = class EnvironmentNotFoundError extends Error {
|
|
147382
|
+
constructor(message) {
|
|
147383
|
+
super(message);
|
|
147384
|
+
}
|
|
147385
|
+
};
|
|
147386
|
+
PackageNotFoundError = class PackageNotFoundError extends Error {
|
|
147387
|
+
constructor(message) {
|
|
147388
|
+
super(message);
|
|
147389
|
+
}
|
|
147390
|
+
};
|
|
147391
|
+
ModelNotFoundError = class ModelNotFoundError extends Error {
|
|
147392
|
+
constructor(message) {
|
|
147393
|
+
super(message);
|
|
147394
|
+
}
|
|
147395
|
+
};
|
|
147396
|
+
ConnectionNotFoundError = class ConnectionNotFoundError extends Error {
|
|
147397
|
+
constructor(message) {
|
|
147398
|
+
super(message);
|
|
147399
|
+
}
|
|
147400
|
+
};
|
|
147401
|
+
ConnectionError = class ConnectionError extends Error {
|
|
147402
|
+
constructor(message) {
|
|
147403
|
+
super(message);
|
|
147404
|
+
}
|
|
147405
|
+
};
|
|
147406
|
+
ConnectionAuthError = class ConnectionAuthError extends Error {
|
|
147407
|
+
constructor(message) {
|
|
147408
|
+
super(message);
|
|
147409
|
+
}
|
|
147410
|
+
};
|
|
147411
|
+
ModelCompilationError = class ModelCompilationError extends Error {
|
|
147412
|
+
constructor(error) {
|
|
147413
|
+
super(error.message);
|
|
147414
|
+
}
|
|
147415
|
+
};
|
|
147416
|
+
FrozenConfigError = class FrozenConfigError extends Error {
|
|
147417
|
+
constructor(message = `Publisher config can't be updated when ${PUBLISHER_CONFIG_NAME} has { "frozenConfig": true }`) {
|
|
147418
|
+
super(message);
|
|
147419
|
+
}
|
|
147420
|
+
};
|
|
147421
|
+
MaterializationNotFoundError = class MaterializationNotFoundError extends Error {
|
|
147422
|
+
constructor(message) {
|
|
147423
|
+
super(message);
|
|
147424
|
+
}
|
|
147425
|
+
};
|
|
147426
|
+
MaterializationConflictError = class MaterializationConflictError extends Error {
|
|
147427
|
+
constructor(message) {
|
|
147428
|
+
super(message);
|
|
147429
|
+
}
|
|
147430
|
+
};
|
|
147431
|
+
InvalidStateTransitionError = class InvalidStateTransitionError extends Error {
|
|
147432
|
+
constructor(message) {
|
|
147433
|
+
super(message);
|
|
147434
|
+
}
|
|
147435
|
+
};
|
|
147436
|
+
ServiceUnavailableError = class ServiceUnavailableError extends Error {
|
|
147437
|
+
constructor(message) {
|
|
147438
|
+
super(message);
|
|
147439
|
+
}
|
|
147440
|
+
};
|
|
147441
|
+
});
|
|
147442
|
+
|
|
147231
147443
|
// ../../node_modules/delayed-stream/lib/delayed_stream.js
|
|
147232
147444
|
var require_delayed_stream = __commonJS((exports, module) => {
|
|
147233
147445
|
var Stream = __require("stream").Stream;
|
|
@@ -199156,6 +199368,464 @@ var require_dist12 = __commonJS((exports) => {
|
|
|
199156
199368
|
exports.default = deferred;
|
|
199157
199369
|
});
|
|
199158
199370
|
|
|
199371
|
+
// src/compile/compile_pool.ts
|
|
199372
|
+
var exports_compile_pool = {};
|
|
199373
|
+
__export(exports_compile_pool, {
|
|
199374
|
+
getCompileWorkerCount: () => getCompileWorkerCount,
|
|
199375
|
+
getCompilePool: () => getCompilePool,
|
|
199376
|
+
__setCompilePoolForTests: () => __setCompilePoolForTests,
|
|
199377
|
+
CompileWorkerPool: () => CompileWorkerPool
|
|
199378
|
+
});
|
|
199379
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
199380
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
199381
|
+
import { Worker } from "node:worker_threads";
|
|
199382
|
+
function getCompileWorkerCount() {
|
|
199383
|
+
const raw = process.env.MALLOY_COMPILE_WORKERS;
|
|
199384
|
+
if (raw === undefined)
|
|
199385
|
+
return 0;
|
|
199386
|
+
const parsed = Number.parseInt(raw, 10);
|
|
199387
|
+
if (!Number.isFinite(parsed) || parsed < 0)
|
|
199388
|
+
return 0;
|
|
199389
|
+
return parsed;
|
|
199390
|
+
}
|
|
199391
|
+
function resolveWorkerScript() {
|
|
199392
|
+
const thisFile = fileURLToPath2(import.meta.url);
|
|
199393
|
+
const thisDir = dirname3(thisFile);
|
|
199394
|
+
const distCandidate = join3(thisDir, "compile_worker.mjs");
|
|
199395
|
+
if (thisFile.endsWith(".mjs") || thisFile.endsWith(".js")) {
|
|
199396
|
+
return new URL(`file://${distCandidate}`);
|
|
199397
|
+
}
|
|
199398
|
+
const tsCandidate = join3(thisDir, "compile_worker.ts");
|
|
199399
|
+
return new URL(`file://${tsCandidate}`);
|
|
199400
|
+
}
|
|
199401
|
+
|
|
199402
|
+
class CompileWorkerPool {
|
|
199403
|
+
workers = [];
|
|
199404
|
+
maxWorkers;
|
|
199405
|
+
nextWorkerId = 0;
|
|
199406
|
+
jobs = new Map;
|
|
199407
|
+
nextJobId = 0;
|
|
199408
|
+
shuttingDown = false;
|
|
199409
|
+
workerScript;
|
|
199410
|
+
constructor(maxWorkers, workerScript) {
|
|
199411
|
+
this.maxWorkers = maxWorkers;
|
|
199412
|
+
this.workerScript = workerScript ?? resolveWorkerScript();
|
|
199413
|
+
}
|
|
199414
|
+
get enabled() {
|
|
199415
|
+
return this.maxWorkers > 0;
|
|
199416
|
+
}
|
|
199417
|
+
get size() {
|
|
199418
|
+
return this.workers.filter((w) => !w.exited).length;
|
|
199419
|
+
}
|
|
199420
|
+
async compile(request) {
|
|
199421
|
+
return this.dispatchJob({
|
|
199422
|
+
label: `model=${request.modelPath}`,
|
|
199423
|
+
malloyConfig: request.malloyConfig,
|
|
199424
|
+
urlReader: request.urlReader,
|
|
199425
|
+
buildMessage: (jobId) => ({
|
|
199426
|
+
type: "compile",
|
|
199427
|
+
requestId: jobId,
|
|
199428
|
+
packagePath: request.packagePath,
|
|
199429
|
+
modelPath: request.modelPath,
|
|
199430
|
+
defaultConnectionName: request.defaultConnectionName,
|
|
199431
|
+
buildManifest: request.buildManifest
|
|
199432
|
+
})
|
|
199433
|
+
});
|
|
199434
|
+
}
|
|
199435
|
+
async compileInline(request) {
|
|
199436
|
+
return this.dispatchJob({
|
|
199437
|
+
label: "inline-source",
|
|
199438
|
+
malloyConfig: request.malloyConfig,
|
|
199439
|
+
urlReader: request.urlReader,
|
|
199440
|
+
buildMessage: (jobId) => ({
|
|
199441
|
+
type: "compile",
|
|
199442
|
+
requestId: jobId,
|
|
199443
|
+
packagePath: request.packagePath,
|
|
199444
|
+
inlineSource: request.source,
|
|
199445
|
+
importBaseURL: request.importBaseURL,
|
|
199446
|
+
defaultConnectionName: request.defaultConnectionName,
|
|
199447
|
+
buildManifest: request.buildManifest
|
|
199448
|
+
})
|
|
199449
|
+
});
|
|
199450
|
+
}
|
|
199451
|
+
async dispatchJob(opts) {
|
|
199452
|
+
if (!this.enabled) {
|
|
199453
|
+
throw new Error("CompileWorkerPool called while disabled (MALLOY_COMPILE_WORKERS=0)");
|
|
199454
|
+
}
|
|
199455
|
+
if (this.shuttingDown) {
|
|
199456
|
+
throw new Error("CompileWorkerPool is shutting down");
|
|
199457
|
+
}
|
|
199458
|
+
const worker = await this.acquireWorker();
|
|
199459
|
+
this.nextJobId += 1;
|
|
199460
|
+
const jobId = `job-${this.nextJobId}`;
|
|
199461
|
+
return new Promise((resolve3, reject) => {
|
|
199462
|
+
const timeout = setTimeout(() => {
|
|
199463
|
+
this.failJob(jobId, new Error(`Compile job timed out after ${COMPILE_JOB_TIMEOUT_MS}ms (${opts.label})`));
|
|
199464
|
+
}, COMPILE_JOB_TIMEOUT_MS);
|
|
199465
|
+
this.jobs.set(jobId, {
|
|
199466
|
+
jobId,
|
|
199467
|
+
connections: opts.malloyConfig.connections,
|
|
199468
|
+
urlReader: opts.urlReader ?? defaultUrlReader,
|
|
199469
|
+
resolve: (result) => {
|
|
199470
|
+
clearTimeout(timeout);
|
|
199471
|
+
resolve3(adaptResult(result));
|
|
199472
|
+
},
|
|
199473
|
+
reject: (err) => {
|
|
199474
|
+
clearTimeout(timeout);
|
|
199475
|
+
reject(err);
|
|
199476
|
+
},
|
|
199477
|
+
timeout
|
|
199478
|
+
});
|
|
199479
|
+
worker.inFlight.add(jobId);
|
|
199480
|
+
worker.worker.postMessage(opts.buildMessage(jobId));
|
|
199481
|
+
});
|
|
199482
|
+
}
|
|
199483
|
+
async shutdown() {
|
|
199484
|
+
if (this.shuttingDown)
|
|
199485
|
+
return;
|
|
199486
|
+
this.shuttingDown = true;
|
|
199487
|
+
const exits = this.workers.map((pw) => new Promise((resolve3) => {
|
|
199488
|
+
if (pw.exited) {
|
|
199489
|
+
resolve3();
|
|
199490
|
+
return;
|
|
199491
|
+
}
|
|
199492
|
+
pw.worker.once("exit", () => resolve3());
|
|
199493
|
+
const msg = { type: "shutdown" };
|
|
199494
|
+
pw.worker.postMessage(msg);
|
|
199495
|
+
setTimeout(() => {
|
|
199496
|
+
if (!pw.exited) {
|
|
199497
|
+
pw.worker.terminate().finally(() => resolve3());
|
|
199498
|
+
}
|
|
199499
|
+
}, 1e4);
|
|
199500
|
+
}));
|
|
199501
|
+
await Promise.all(exits);
|
|
199502
|
+
}
|
|
199503
|
+
async acquireWorker() {
|
|
199504
|
+
this.workers.splice(0, this.workers.length, ...this.workers.filter((w) => !w.exited));
|
|
199505
|
+
if (this.workers.length < this.maxWorkers) {
|
|
199506
|
+
const pw = this.spawnWorker();
|
|
199507
|
+
this.workers.push(pw);
|
|
199508
|
+
await pw.ready;
|
|
199509
|
+
return pw;
|
|
199510
|
+
}
|
|
199511
|
+
const alive = this.workers.filter((w) => !w.exited);
|
|
199512
|
+
let best = alive[0];
|
|
199513
|
+
for (const candidate of alive) {
|
|
199514
|
+
if (candidate.inFlight.size < best.inFlight.size) {
|
|
199515
|
+
best = candidate;
|
|
199516
|
+
}
|
|
199517
|
+
}
|
|
199518
|
+
await best.ready;
|
|
199519
|
+
return best;
|
|
199520
|
+
}
|
|
199521
|
+
spawnWorker() {
|
|
199522
|
+
this.nextWorkerId += 1;
|
|
199523
|
+
const id = this.nextWorkerId;
|
|
199524
|
+
logger.info(`CompileWorkerPool: spawning worker #${id} (script=${this.workerScript.toString()})`);
|
|
199525
|
+
const worker = new Worker(this.workerScript, {
|
|
199526
|
+
name: `malloy-compile-worker-${id}`
|
|
199527
|
+
});
|
|
199528
|
+
let readyResolve;
|
|
199529
|
+
const ready = new Promise((r) => readyResolve = r);
|
|
199530
|
+
const pw = {
|
|
199531
|
+
id,
|
|
199532
|
+
worker,
|
|
199533
|
+
ready,
|
|
199534
|
+
inFlight: new Set,
|
|
199535
|
+
exited: false
|
|
199536
|
+
};
|
|
199537
|
+
worker.on("message", (msg) => {
|
|
199538
|
+
this.handleWorkerMessage(pw, msg, readyResolve);
|
|
199539
|
+
});
|
|
199540
|
+
worker.on("error", (err) => {
|
|
199541
|
+
logger.error(`CompileWorkerPool: worker #${id} errored`, {
|
|
199542
|
+
error: err
|
|
199543
|
+
});
|
|
199544
|
+
});
|
|
199545
|
+
worker.on("exit", (code) => {
|
|
199546
|
+
pw.exited = true;
|
|
199547
|
+
logger.warn(`CompileWorkerPool: worker #${id} exited (code=${code}, inFlight=${pw.inFlight.size})`);
|
|
199548
|
+
for (const jobId of pw.inFlight) {
|
|
199549
|
+
this.failJob(jobId, new Error(`Compile worker #${id} exited unexpectedly (code=${code})`));
|
|
199550
|
+
}
|
|
199551
|
+
pw.inFlight.clear();
|
|
199552
|
+
});
|
|
199553
|
+
return pw;
|
|
199554
|
+
}
|
|
199555
|
+
handleWorkerMessage(pw, msg, markReady) {
|
|
199556
|
+
switch (msg.type) {
|
|
199557
|
+
case "ready":
|
|
199558
|
+
markReady();
|
|
199559
|
+
return;
|
|
199560
|
+
case "compile-result":
|
|
199561
|
+
this.completeJob(pw, msg);
|
|
199562
|
+
return;
|
|
199563
|
+
case "compile-error":
|
|
199564
|
+
this.errorJob(pw, msg);
|
|
199565
|
+
return;
|
|
199566
|
+
case "connection-metadata":
|
|
199567
|
+
this.handleConnectionMetadata(pw, msg);
|
|
199568
|
+
return;
|
|
199569
|
+
case "schema-for-tables":
|
|
199570
|
+
this.handleSchemaForTables(pw, msg);
|
|
199571
|
+
return;
|
|
199572
|
+
case "schema-for-sql":
|
|
199573
|
+
this.handleSchemaForSql(pw, msg);
|
|
199574
|
+
return;
|
|
199575
|
+
case "read-url":
|
|
199576
|
+
this.handleReadUrl(pw, msg);
|
|
199577
|
+
return;
|
|
199578
|
+
default: {
|
|
199579
|
+
const exhaustive = msg;
|
|
199580
|
+
return;
|
|
199581
|
+
}
|
|
199582
|
+
}
|
|
199583
|
+
}
|
|
199584
|
+
async handleConnectionMetadata(pw, msg) {
|
|
199585
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199586
|
+
const reply = (response) => {
|
|
199587
|
+
pw.worker.postMessage(response);
|
|
199588
|
+
};
|
|
199589
|
+
if (!ctx) {
|
|
199590
|
+
reply({
|
|
199591
|
+
type: "rpc-error",
|
|
199592
|
+
requestId: msg.requestId,
|
|
199593
|
+
ok: false,
|
|
199594
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199595
|
+
});
|
|
199596
|
+
return;
|
|
199597
|
+
}
|
|
199598
|
+
try {
|
|
199599
|
+
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199600
|
+
reply({
|
|
199601
|
+
type: "connection-metadata-response",
|
|
199602
|
+
requestId: msg.requestId,
|
|
199603
|
+
ok: true,
|
|
199604
|
+
metadata: {
|
|
199605
|
+
name: msg.connectionName,
|
|
199606
|
+
dialectName: conn.dialectName,
|
|
199607
|
+
digest: typeof conn.getDigest === "function" ? conn.getDigest() : msg.connectionName
|
|
199608
|
+
}
|
|
199609
|
+
});
|
|
199610
|
+
} catch (error) {
|
|
199611
|
+
reply({
|
|
199612
|
+
type: "rpc-error",
|
|
199613
|
+
requestId: msg.requestId,
|
|
199614
|
+
ok: false,
|
|
199615
|
+
error: serializeError(error)
|
|
199616
|
+
});
|
|
199617
|
+
}
|
|
199618
|
+
}
|
|
199619
|
+
completeJob(pw, msg) {
|
|
199620
|
+
const ctx = this.jobs.get(msg.requestId);
|
|
199621
|
+
if (!ctx)
|
|
199622
|
+
return;
|
|
199623
|
+
this.jobs.delete(msg.requestId);
|
|
199624
|
+
pw.inFlight.delete(msg.requestId);
|
|
199625
|
+
ctx.resolve(msg);
|
|
199626
|
+
}
|
|
199627
|
+
errorJob(pw, msg) {
|
|
199628
|
+
const ctx = this.jobs.get(msg.requestId);
|
|
199629
|
+
if (!ctx)
|
|
199630
|
+
return;
|
|
199631
|
+
this.jobs.delete(msg.requestId);
|
|
199632
|
+
pw.inFlight.delete(msg.requestId);
|
|
199633
|
+
ctx.reject(deserializeError(msg.error));
|
|
199634
|
+
}
|
|
199635
|
+
failJob(jobId, error) {
|
|
199636
|
+
const ctx = this.jobs.get(jobId);
|
|
199637
|
+
if (!ctx)
|
|
199638
|
+
return;
|
|
199639
|
+
this.jobs.delete(jobId);
|
|
199640
|
+
ctx.reject(error);
|
|
199641
|
+
}
|
|
199642
|
+
async handleSchemaForTables(pw, msg) {
|
|
199643
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199644
|
+
const reply = (response) => {
|
|
199645
|
+
pw.worker.postMessage(response);
|
|
199646
|
+
};
|
|
199647
|
+
if (!ctx) {
|
|
199648
|
+
reply({
|
|
199649
|
+
type: "rpc-error",
|
|
199650
|
+
requestId: msg.requestId,
|
|
199651
|
+
ok: false,
|
|
199652
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199653
|
+
});
|
|
199654
|
+
return;
|
|
199655
|
+
}
|
|
199656
|
+
try {
|
|
199657
|
+
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199658
|
+
const result = await conn.fetchSchemaForTables(msg.tables, buildFetchOptions(msg.options));
|
|
199659
|
+
reply({
|
|
199660
|
+
type: "schema-for-tables-response",
|
|
199661
|
+
requestId: msg.requestId,
|
|
199662
|
+
ok: true,
|
|
199663
|
+
schemas: result.schemas,
|
|
199664
|
+
errors: result.errors
|
|
199665
|
+
});
|
|
199666
|
+
} catch (error) {
|
|
199667
|
+
reply({
|
|
199668
|
+
type: "rpc-error",
|
|
199669
|
+
requestId: msg.requestId,
|
|
199670
|
+
ok: false,
|
|
199671
|
+
error: serializeError(error)
|
|
199672
|
+
});
|
|
199673
|
+
}
|
|
199674
|
+
}
|
|
199675
|
+
async handleSchemaForSql(pw, msg) {
|
|
199676
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199677
|
+
const reply = (response) => {
|
|
199678
|
+
pw.worker.postMessage(response);
|
|
199679
|
+
};
|
|
199680
|
+
if (!ctx) {
|
|
199681
|
+
reply({
|
|
199682
|
+
type: "rpc-error",
|
|
199683
|
+
requestId: msg.requestId,
|
|
199684
|
+
ok: false,
|
|
199685
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199686
|
+
});
|
|
199687
|
+
return;
|
|
199688
|
+
}
|
|
199689
|
+
try {
|
|
199690
|
+
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199691
|
+
const result = await conn.fetchSchemaForSQLStruct(msg.sentence, buildFetchOptions(msg.options));
|
|
199692
|
+
if (result.error !== undefined) {
|
|
199693
|
+
reply({
|
|
199694
|
+
type: "schema-for-sql-response",
|
|
199695
|
+
requestId: msg.requestId,
|
|
199696
|
+
ok: true,
|
|
199697
|
+
error: result.error
|
|
199698
|
+
});
|
|
199699
|
+
} else {
|
|
199700
|
+
reply({
|
|
199701
|
+
type: "schema-for-sql-response",
|
|
199702
|
+
requestId: msg.requestId,
|
|
199703
|
+
ok: true,
|
|
199704
|
+
structDef: result.structDef
|
|
199705
|
+
});
|
|
199706
|
+
}
|
|
199707
|
+
} catch (error) {
|
|
199708
|
+
reply({
|
|
199709
|
+
type: "rpc-error",
|
|
199710
|
+
requestId: msg.requestId,
|
|
199711
|
+
ok: false,
|
|
199712
|
+
error: serializeError(error)
|
|
199713
|
+
});
|
|
199714
|
+
}
|
|
199715
|
+
}
|
|
199716
|
+
async handleReadUrl(pw, msg) {
|
|
199717
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199718
|
+
const reply = (response) => {
|
|
199719
|
+
pw.worker.postMessage(response);
|
|
199720
|
+
};
|
|
199721
|
+
if (!ctx) {
|
|
199722
|
+
reply({
|
|
199723
|
+
type: "rpc-error",
|
|
199724
|
+
requestId: msg.requestId,
|
|
199725
|
+
ok: false,
|
|
199726
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199727
|
+
});
|
|
199728
|
+
return;
|
|
199729
|
+
}
|
|
199730
|
+
try {
|
|
199731
|
+
const raw = await ctx.urlReader.readURL(new URL(msg.url));
|
|
199732
|
+
const contents = typeof raw === "string" ? raw : raw.contents;
|
|
199733
|
+
reply({
|
|
199734
|
+
type: "read-url-response",
|
|
199735
|
+
requestId: msg.requestId,
|
|
199736
|
+
ok: true,
|
|
199737
|
+
contents
|
|
199738
|
+
});
|
|
199739
|
+
} catch (error) {
|
|
199740
|
+
reply({
|
|
199741
|
+
type: "rpc-error",
|
|
199742
|
+
requestId: msg.requestId,
|
|
199743
|
+
ok: false,
|
|
199744
|
+
error: serializeError(error)
|
|
199745
|
+
});
|
|
199746
|
+
}
|
|
199747
|
+
}
|
|
199748
|
+
}
|
|
199749
|
+
function buildFetchOptions(options) {
|
|
199750
|
+
const out = {};
|
|
199751
|
+
if (options.refreshTimestamp !== undefined) {
|
|
199752
|
+
out.refreshTimestamp = options.refreshTimestamp;
|
|
199753
|
+
}
|
|
199754
|
+
if (options.modelAnnotation !== undefined) {
|
|
199755
|
+
out.modelAnnotation = options.modelAnnotation;
|
|
199756
|
+
}
|
|
199757
|
+
return out;
|
|
199758
|
+
}
|
|
199759
|
+
function adaptResult(result) {
|
|
199760
|
+
return {
|
|
199761
|
+
modelDef: result.modelDef,
|
|
199762
|
+
sourceInfos: result.sourceInfos,
|
|
199763
|
+
sources: result.sources,
|
|
199764
|
+
queries: result.queries,
|
|
199765
|
+
filterMap: new Map(result.filterMap.map(([k, v]) => [k, v])),
|
|
199766
|
+
givens: result.givens,
|
|
199767
|
+
compileDurationMs: result.compileDurationMs
|
|
199768
|
+
};
|
|
199769
|
+
}
|
|
199770
|
+
function serializeError(error) {
|
|
199771
|
+
if (error instanceof Error) {
|
|
199772
|
+
return {
|
|
199773
|
+
name: error.name,
|
|
199774
|
+
message: error.message,
|
|
199775
|
+
stack: error.stack
|
|
199776
|
+
};
|
|
199777
|
+
}
|
|
199778
|
+
return { name: "Error", message: String(error) };
|
|
199779
|
+
}
|
|
199780
|
+
function deserializeError(serialized) {
|
|
199781
|
+
const err = new Error(serialized.message);
|
|
199782
|
+
err.name = serialized.name;
|
|
199783
|
+
if (serialized.stack)
|
|
199784
|
+
err.stack = serialized.stack;
|
|
199785
|
+
if (serialized.malloyProblems) {
|
|
199786
|
+
err.problems = serialized.malloyProblems;
|
|
199787
|
+
}
|
|
199788
|
+
if (serialized.isCompilationError) {
|
|
199789
|
+
const wrapped = new ModelCompilationError(err);
|
|
199790
|
+
if (serialized.stack)
|
|
199791
|
+
wrapped.stack = serialized.stack;
|
|
199792
|
+
return wrapped;
|
|
199793
|
+
}
|
|
199794
|
+
return err;
|
|
199795
|
+
}
|
|
199796
|
+
function getCompilePool() {
|
|
199797
|
+
if (singleton === null) {
|
|
199798
|
+
const n = getCompileWorkerCount();
|
|
199799
|
+
singleton = new CompileWorkerPool(n);
|
|
199800
|
+
if (n > 0) {
|
|
199801
|
+
logger.info(`Malloy compile worker pool enabled (size=${n}). Set MALLOY_COMPILE_WORKERS=0 to disable.`);
|
|
199802
|
+
} else {
|
|
199803
|
+
logger.info("Malloy compile worker pool DISABLED (MALLOY_COMPILE_WORKERS=0). Compile runs on the main event loop.");
|
|
199804
|
+
}
|
|
199805
|
+
}
|
|
199806
|
+
return singleton;
|
|
199807
|
+
}
|
|
199808
|
+
async function __setCompilePoolForTests(pool) {
|
|
199809
|
+
if (singleton && singleton !== pool) {
|
|
199810
|
+
await singleton.shutdown();
|
|
199811
|
+
}
|
|
199812
|
+
singleton = pool;
|
|
199813
|
+
}
|
|
199814
|
+
var COMPILE_JOB_TIMEOUT_MS, defaultUrlReader, singleton = null;
|
|
199815
|
+
var init_compile_pool = __esm(() => {
|
|
199816
|
+
init_errors();
|
|
199817
|
+
init_logger();
|
|
199818
|
+
COMPILE_JOB_TIMEOUT_MS = Number.parseInt(process.env.MALLOY_COMPILE_JOB_TIMEOUT_MS ?? "120000", 10);
|
|
199819
|
+
defaultUrlReader = {
|
|
199820
|
+
readURL: async (url2) => {
|
|
199821
|
+
const { promises: fs3 } = await import("fs");
|
|
199822
|
+
const { fileURLToPath: fileURLToPath3 } = await import("url");
|
|
199823
|
+
const filePath = url2.protocol === "file:" ? fileURLToPath3(url2) : url2.toString();
|
|
199824
|
+
return fs3.readFile(filePath, "utf8");
|
|
199825
|
+
}
|
|
199826
|
+
};
|
|
199827
|
+
});
|
|
199828
|
+
|
|
199159
199829
|
// ../../node_modules/concat-map/index.js
|
|
199160
199830
|
var require_concat_map = __commonJS((exports, module) => {
|
|
199161
199831
|
module.exports = function(xs, fn) {
|
|
@@ -209122,7 +209792,7 @@ var require_util14 = __commonJS((exports) => {
|
|
|
209122
209792
|
return path12;
|
|
209123
209793
|
}
|
|
209124
209794
|
exports.normalize = normalize2;
|
|
209125
|
-
function
|
|
209795
|
+
function join9(aRoot, aPath) {
|
|
209126
209796
|
if (aRoot === "") {
|
|
209127
209797
|
aRoot = ".";
|
|
209128
209798
|
}
|
|
@@ -209154,7 +209824,7 @@ var require_util14 = __commonJS((exports) => {
|
|
|
209154
209824
|
}
|
|
209155
209825
|
return joined;
|
|
209156
209826
|
}
|
|
209157
|
-
exports.join =
|
|
209827
|
+
exports.join = join9;
|
|
209158
209828
|
exports.isAbsolute = function(aPath) {
|
|
209159
209829
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
209160
209830
|
};
|
|
@@ -209327,7 +209997,7 @@ var require_util14 = __commonJS((exports) => {
|
|
|
209327
209997
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
209328
209998
|
}
|
|
209329
209999
|
}
|
|
209330
|
-
sourceURL =
|
|
210000
|
+
sourceURL = join9(urlGenerate(parsed), sourceURL);
|
|
209331
210001
|
}
|
|
209332
210002
|
return normalize2(sourceURL);
|
|
209333
210003
|
}
|
|
@@ -211725,6 +212395,7 @@ var require_lib8 = __commonJS((exports, module) => {
|
|
|
211725
212395
|
});
|
|
211726
212396
|
|
|
211727
212397
|
// src/instrumentation.ts
|
|
212398
|
+
init_logger();
|
|
211728
212399
|
var import_api = __toESM(require_src(), 1);
|
|
211729
212400
|
var import_auto_instrumentations_node = __toESM(require_src59(), 1);
|
|
211730
212401
|
var import_exporter_logs_otlp_proto = __toESM(require_src66(), 1);
|
|
@@ -211736,94 +212407,6 @@ var import_sdk_logs = __toESM(require_src75(), 1);
|
|
|
211736
212407
|
var import_sdk_node = __toESM(require_src106(), 1);
|
|
211737
212408
|
var import_sdk_trace_base = __toESM(require_src82(), 1);
|
|
211738
212409
|
var import_semantic_conventions = __toESM(require_src2(), 1);
|
|
211739
|
-
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
211740
|
-
|
|
211741
|
-
// src/logger.ts
|
|
211742
|
-
var import_winston = __toESM(require_winston(), 1);
|
|
211743
|
-
var isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
|
|
211744
|
-
var VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
|
|
211745
|
-
var getLogLevel = () => {
|
|
211746
|
-
if (process.env.LOG_LEVEL) {
|
|
211747
|
-
const logLevel = process.env.LOG_LEVEL.toLowerCase();
|
|
211748
|
-
if (VALID_LOG_LEVELS.includes(logLevel)) {
|
|
211749
|
-
return logLevel;
|
|
211750
|
-
} else {
|
|
211751
|
-
console.error(`Invalid log level: ${process.env.LOG_LEVEL}. Valid log levels are: ${VALID_LOG_LEVELS.join(", ")}. Defaulting to "debug".`);
|
|
211752
|
-
}
|
|
211753
|
-
}
|
|
211754
|
-
return "debug";
|
|
211755
|
-
};
|
|
211756
|
-
var logger = import_winston.default.createLogger({
|
|
211757
|
-
level: getLogLevel(),
|
|
211758
|
-
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()),
|
|
211759
|
-
transports: [new import_winston.default.transports.Console]
|
|
211760
|
-
});
|
|
211761
|
-
function extractTraceIdFromTraceparent(traceparent) {
|
|
211762
|
-
if (!traceparent) {
|
|
211763
|
-
return;
|
|
211764
|
-
}
|
|
211765
|
-
const parts = traceparent.split("-");
|
|
211766
|
-
const traceId = parts.length >= 2 ? parts[1] : parts.length == 1 ? parts[0] : undefined;
|
|
211767
|
-
if (traceId && traceId.length === 32 && /^[0-9a-fA-F]{32}$/.test(traceId)) {
|
|
211768
|
-
return traceId;
|
|
211769
|
-
}
|
|
211770
|
-
return;
|
|
211771
|
-
}
|
|
211772
|
-
var DISABLE_RESPONSE_LOGGING = process.env.DISABLE_RESPONSE_LOGGING === "true" || process.env.DISABLE_RESPONSE_LOGGING === "1";
|
|
211773
|
-
function formatDuration(durationMs) {
|
|
211774
|
-
if (durationMs >= 1000) {
|
|
211775
|
-
const seconds = durationMs / 1000;
|
|
211776
|
-
return `${seconds.toFixed(2)}s`;
|
|
211777
|
-
}
|
|
211778
|
-
return `${durationMs.toFixed(2)}ms`;
|
|
211779
|
-
}
|
|
211780
|
-
var loggerMiddleware = (req, res, next) => {
|
|
211781
|
-
const startTime = performance.now();
|
|
211782
|
-
const resJson = res.json;
|
|
211783
|
-
res.json = (body) => {
|
|
211784
|
-
res.locals.body = body;
|
|
211785
|
-
return resJson.call(res, body);
|
|
211786
|
-
};
|
|
211787
|
-
res.on("finish", () => {
|
|
211788
|
-
const endTime = performance.now();
|
|
211789
|
-
const durationMs = endTime - startTime;
|
|
211790
|
-
const traceparent = req.headers["traceparent"];
|
|
211791
|
-
const traceId = extractTraceIdFromTraceparent(traceparent);
|
|
211792
|
-
const logMetadata = {
|
|
211793
|
-
statusCode: res.statusCode,
|
|
211794
|
-
duration: formatDuration(durationMs),
|
|
211795
|
-
payload: req.body,
|
|
211796
|
-
params: req.params,
|
|
211797
|
-
query: req.query
|
|
211798
|
-
};
|
|
211799
|
-
if (!DISABLE_RESPONSE_LOGGING) {
|
|
211800
|
-
logMetadata.response = res.locals.body;
|
|
211801
|
-
}
|
|
211802
|
-
if (traceId) {
|
|
211803
|
-
logMetadata.traceId = traceId;
|
|
211804
|
-
}
|
|
211805
|
-
if (req.url !== "/metrics" && req.url !== "/health" && req.url !== "/health/liveness" && req.url !== "/health/readiness") {
|
|
211806
|
-
logger.info(`${req.method} ${req.url}`, logMetadata);
|
|
211807
|
-
}
|
|
211808
|
-
});
|
|
211809
|
-
next();
|
|
211810
|
-
};
|
|
211811
|
-
var logAxiosError = (error) => {
|
|
211812
|
-
if (error.response) {
|
|
211813
|
-
logger.error("Axios server-side error", {
|
|
211814
|
-
url: error.response.config.url,
|
|
211815
|
-
status: error.response.status,
|
|
211816
|
-
headers: error.response.headers,
|
|
211817
|
-
data: error.response.data
|
|
211818
|
-
});
|
|
211819
|
-
} else if (error.request) {
|
|
211820
|
-
logger.error("Axios client-side error", { error: error.request });
|
|
211821
|
-
} else {
|
|
211822
|
-
logger.error("Axios unknown error", { error });
|
|
211823
|
-
}
|
|
211824
|
-
};
|
|
211825
|
-
|
|
211826
|
-
// src/instrumentation.ts
|
|
211827
212410
|
var prometheusExporter = null;
|
|
211828
212411
|
var sdk = null;
|
|
211829
212412
|
function getPrometheusMetricsHandler() {
|
|
@@ -211905,26 +212488,6 @@ var httpRequestDuration = meter.createHistogram("http_server_request_duration_ms
|
|
|
211905
212488
|
var httpRequestCount = meter.createCounter("http_server_requests_total", {
|
|
211906
212489
|
description: "Total number of HTTP requests"
|
|
211907
212490
|
});
|
|
211908
|
-
var eventLoopHistogram = monitorEventLoopDelay({ resolution: 20 });
|
|
211909
|
-
eventLoopHistogram.enable();
|
|
211910
|
-
var eventLoopLagP50 = meter.createObservableGauge("publisher_event_loop_lag_p50_ms", {
|
|
211911
|
-
description: "Event loop delay p50 since the last scrape, in milliseconds",
|
|
211912
|
-
unit: "ms"
|
|
211913
|
-
});
|
|
211914
|
-
var eventLoopLagP99 = meter.createObservableGauge("publisher_event_loop_lag_p99_ms", {
|
|
211915
|
-
description: "Event loop delay p99 since the last scrape, in milliseconds",
|
|
211916
|
-
unit: "ms"
|
|
211917
|
-
});
|
|
211918
|
-
var eventLoopLagMax = meter.createObservableGauge("publisher_event_loop_lag_max_ms", {
|
|
211919
|
-
description: "Event loop delay max since the last scrape, in milliseconds",
|
|
211920
|
-
unit: "ms"
|
|
211921
|
-
});
|
|
211922
|
-
meter.addBatchObservableCallback((observableResult) => {
|
|
211923
|
-
observableResult.observe(eventLoopLagP50, eventLoopHistogram.percentile(50) / 1e6);
|
|
211924
|
-
observableResult.observe(eventLoopLagP99, eventLoopHistogram.percentile(99) / 1e6);
|
|
211925
|
-
observableResult.observe(eventLoopLagMax, eventLoopHistogram.max / 1e6);
|
|
211926
|
-
eventLoopHistogram.reset();
|
|
211927
|
-
}, [eventLoopLagP50, eventLoopLagP99, eventLoopLagMax]);
|
|
211928
212491
|
var IGNORED_PATHS = new Set([
|
|
211929
212492
|
"/health",
|
|
211930
212493
|
"/health/liveness",
|
|
@@ -216966,7 +217529,7 @@ var import_express = __toESM(require_express(), 1);
|
|
|
216966
217529
|
var import_http_proxy_middleware = __toESM(require_dist4(), 1);
|
|
216967
217530
|
import * as http2 from "http";
|
|
216968
217531
|
import * as path12 from "path";
|
|
216969
|
-
import { fileURLToPath as
|
|
217532
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
216970
217533
|
|
|
216971
217534
|
// src/controller/compile.controller.ts
|
|
216972
217535
|
class CompileController {
|
|
@@ -216986,148 +217549,9 @@ class CompileController {
|
|
|
216986
217549
|
}
|
|
216987
217550
|
}
|
|
216988
217551
|
|
|
216989
|
-
// src/
|
|
216990
|
-
|
|
216991
|
-
|
|
216992
|
-
// src/constants.ts
|
|
216993
|
-
import os from "os";
|
|
216994
|
-
var API_PREFIX = "/api/v0";
|
|
216995
|
-
var README_NAME = "README.md";
|
|
216996
|
-
var PUBLISHER_CONFIG_NAME = "publisher.config.json";
|
|
216997
|
-
var PACKAGE_MANIFEST_NAME = "publisher.json";
|
|
216998
|
-
var MODEL_FILE_SUFFIX = ".malloy";
|
|
216999
|
-
var NOTEBOOK_FILE_SUFFIX = ".malloynb";
|
|
217000
|
-
var ROW_LIMIT = 1000;
|
|
217001
|
-
var TEMP_DIR_PATH = os.tmpdir();
|
|
217002
|
-
var PUBLISHER_DATA_DIR = "publisher_data";
|
|
217003
|
-
|
|
217004
|
-
// src/errors.ts
|
|
217005
|
-
function internalErrorToHttpError(error) {
|
|
217006
|
-
if (error instanceof BadRequestError) {
|
|
217007
|
-
return httpError(400, error.message);
|
|
217008
|
-
} else if (error instanceof FrozenConfigError) {
|
|
217009
|
-
return httpError(403, error.message);
|
|
217010
|
-
} else if (error instanceof EnvironmentNotFoundError) {
|
|
217011
|
-
return httpError(404, error.message);
|
|
217012
|
-
} else if (error instanceof PackageNotFoundError) {
|
|
217013
|
-
return httpError(404, error.message);
|
|
217014
|
-
} else if (error instanceof ModelNotFoundError) {
|
|
217015
|
-
return httpError(404, error.message);
|
|
217016
|
-
} else if (error instanceof MalloyError) {
|
|
217017
|
-
return httpError(400, error.message);
|
|
217018
|
-
} else if (error instanceof ConnectionNotFoundError) {
|
|
217019
|
-
return httpError(404, error.message);
|
|
217020
|
-
} else if (error instanceof ConnectionAuthError) {
|
|
217021
|
-
return httpError(422, error.message);
|
|
217022
|
-
} else if (error instanceof ModelCompilationError) {
|
|
217023
|
-
return httpError(424, error.message);
|
|
217024
|
-
} else if (error instanceof ConnectionError) {
|
|
217025
|
-
return httpError(502, error.message);
|
|
217026
|
-
} else if (error instanceof MaterializationNotFoundError) {
|
|
217027
|
-
return httpError(404, error.message);
|
|
217028
|
-
} else if (error instanceof MaterializationConflictError) {
|
|
217029
|
-
return httpError(409, error.message);
|
|
217030
|
-
} else if (error instanceof InvalidStateTransitionError) {
|
|
217031
|
-
return httpError(409, error.message);
|
|
217032
|
-
} else if (error instanceof ServiceUnavailableError) {
|
|
217033
|
-
return httpError(503, error.message);
|
|
217034
|
-
} else {
|
|
217035
|
-
return httpError(500, error.message);
|
|
217036
|
-
}
|
|
217037
|
-
}
|
|
217038
|
-
function httpError(code, message) {
|
|
217039
|
-
return {
|
|
217040
|
-
status: code,
|
|
217041
|
-
json: {
|
|
217042
|
-
code,
|
|
217043
|
-
message
|
|
217044
|
-
}
|
|
217045
|
-
};
|
|
217046
|
-
}
|
|
217047
|
-
|
|
217048
|
-
class NotImplementedError extends Error {
|
|
217049
|
-
constructor(message) {
|
|
217050
|
-
super(message);
|
|
217051
|
-
}
|
|
217052
|
-
}
|
|
217053
|
-
|
|
217054
|
-
class BadRequestError extends Error {
|
|
217055
|
-
constructor(message) {
|
|
217056
|
-
super(message);
|
|
217057
|
-
}
|
|
217058
|
-
}
|
|
217059
|
-
|
|
217060
|
-
class EnvironmentNotFoundError extends Error {
|
|
217061
|
-
constructor(message) {
|
|
217062
|
-
super(message);
|
|
217063
|
-
}
|
|
217064
|
-
}
|
|
217065
|
-
|
|
217066
|
-
class PackageNotFoundError extends Error {
|
|
217067
|
-
constructor(message) {
|
|
217068
|
-
super(message);
|
|
217069
|
-
}
|
|
217070
|
-
}
|
|
217071
|
-
|
|
217072
|
-
class ModelNotFoundError extends Error {
|
|
217073
|
-
constructor(message) {
|
|
217074
|
-
super(message);
|
|
217075
|
-
}
|
|
217076
|
-
}
|
|
217077
|
-
|
|
217078
|
-
class ConnectionNotFoundError extends Error {
|
|
217079
|
-
constructor(message) {
|
|
217080
|
-
super(message);
|
|
217081
|
-
}
|
|
217082
|
-
}
|
|
217083
|
-
|
|
217084
|
-
class ConnectionError extends Error {
|
|
217085
|
-
constructor(message) {
|
|
217086
|
-
super(message);
|
|
217087
|
-
}
|
|
217088
|
-
}
|
|
217089
|
-
|
|
217090
|
-
class ConnectionAuthError extends Error {
|
|
217091
|
-
constructor(message) {
|
|
217092
|
-
super(message);
|
|
217093
|
-
}
|
|
217094
|
-
}
|
|
217095
|
-
|
|
217096
|
-
class ModelCompilationError extends Error {
|
|
217097
|
-
constructor(error) {
|
|
217098
|
-
super(error.message);
|
|
217099
|
-
}
|
|
217100
|
-
}
|
|
217101
|
-
|
|
217102
|
-
class FrozenConfigError extends Error {
|
|
217103
|
-
constructor(message = `Publisher config can't be updated when ${PUBLISHER_CONFIG_NAME} has { "frozenConfig": true }`) {
|
|
217104
|
-
super(message);
|
|
217105
|
-
}
|
|
217106
|
-
}
|
|
217107
|
-
|
|
217108
|
-
class MaterializationNotFoundError extends Error {
|
|
217109
|
-
constructor(message) {
|
|
217110
|
-
super(message);
|
|
217111
|
-
}
|
|
217112
|
-
}
|
|
217113
|
-
|
|
217114
|
-
class MaterializationConflictError extends Error {
|
|
217115
|
-
constructor(message) {
|
|
217116
|
-
super(message);
|
|
217117
|
-
}
|
|
217118
|
-
}
|
|
217119
|
-
|
|
217120
|
-
class InvalidStateTransitionError extends Error {
|
|
217121
|
-
constructor(message) {
|
|
217122
|
-
super(message);
|
|
217123
|
-
}
|
|
217124
|
-
}
|
|
217125
|
-
|
|
217126
|
-
class ServiceUnavailableError extends Error {
|
|
217127
|
-
constructor(message) {
|
|
217128
|
-
super(message);
|
|
217129
|
-
}
|
|
217130
|
-
}
|
|
217552
|
+
// src/controller/connection.controller.ts
|
|
217553
|
+
init_errors();
|
|
217554
|
+
init_logger();
|
|
217131
217555
|
|
|
217132
217556
|
// src/service/connection.ts
|
|
217133
217557
|
import"@malloydata/db-bigquery";
|
|
@@ -220412,10 +220836,12 @@ var {
|
|
|
220412
220836
|
} = axios_default;
|
|
220413
220837
|
|
|
220414
220838
|
// src/service/connection.ts
|
|
220839
|
+
init_logger();
|
|
220415
220840
|
import fs from "fs/promises";
|
|
220416
220841
|
import path2 from "path";
|
|
220417
220842
|
|
|
220418
220843
|
// src/pg_helpers.ts
|
|
220844
|
+
init_errors();
|
|
220419
220845
|
function pgConnectTimeoutSeconds() {
|
|
220420
220846
|
const raw = process.env.PG_CONNECT_TIMEOUT_SECONDS;
|
|
220421
220847
|
if (!raw)
|
|
@@ -221666,6 +222092,8 @@ async function testConnectionConfig(connectionConfig) {
|
|
|
221666
222092
|
}
|
|
221667
222093
|
|
|
221668
222094
|
// src/service/connection_service.ts
|
|
222095
|
+
init_errors();
|
|
222096
|
+
init_logger();
|
|
221669
222097
|
async function runEnvironmentConnectionUpdate(environment, fn) {
|
|
221670
222098
|
if (environment.runConnectionUpdateExclusive) {
|
|
221671
222099
|
return environment.runConnectionUpdateExclusive(fn);
|
|
@@ -221777,11 +222205,13 @@ class ConnectionService {
|
|
|
221777
222205
|
}
|
|
221778
222206
|
|
|
221779
222207
|
// src/service/db_utils.ts
|
|
222208
|
+
init_logger();
|
|
221780
222209
|
var import_bigquery = __toESM(require_src121(), 1);
|
|
221781
222210
|
import { ClientSecretCredential } from "@azure/identity";
|
|
221782
222211
|
import { ContainerClient } from "@azure/storage-blob";
|
|
221783
222212
|
|
|
221784
222213
|
// src/service/gcs_s3_utils.ts
|
|
222214
|
+
init_logger();
|
|
221785
222215
|
var import_client_s3 = __toESM(require_dist_cjs75(), 1);
|
|
221786
222216
|
function gcsConnectionToCredentials(gcsConnection) {
|
|
221787
222217
|
return {
|
|
@@ -223129,6 +223559,8 @@ class DatabaseController {
|
|
|
223129
223559
|
}
|
|
223130
223560
|
|
|
223131
223561
|
// src/controller/model.controller.ts
|
|
223562
|
+
init_errors();
|
|
223563
|
+
|
|
223132
223564
|
class ModelController {
|
|
223133
223565
|
environmentStore;
|
|
223134
223566
|
constructor(environmentStore) {
|
|
@@ -223190,6 +223622,9 @@ class ModelController {
|
|
|
223190
223622
|
}
|
|
223191
223623
|
|
|
223192
223624
|
// src/controller/package.controller.ts
|
|
223625
|
+
init_errors();
|
|
223626
|
+
init_logger();
|
|
223627
|
+
|
|
223193
223628
|
class PackageController {
|
|
223194
223629
|
environmentStore;
|
|
223195
223630
|
manifestService;
|
|
@@ -223302,6 +223737,8 @@ class PackageController {
|
|
|
223302
223737
|
}
|
|
223303
223738
|
|
|
223304
223739
|
// src/controller/query.controller.ts
|
|
223740
|
+
init_constants();
|
|
223741
|
+
init_errors();
|
|
223305
223742
|
var import_render_validator = __toESM(require_dist10(), 1);
|
|
223306
223743
|
function bigIntReplacer(_key, value) {
|
|
223307
223744
|
if (typeof value === "bigint") {
|
|
@@ -224905,6 +225342,7 @@ function watch(paths, options = {}) {
|
|
|
224905
225342
|
var esm_default = { watch, FSWatcher };
|
|
224906
225343
|
|
|
224907
225344
|
// src/controller/watch-mode.controller.ts
|
|
225345
|
+
init_logger();
|
|
224908
225346
|
import path11 from "path";
|
|
224909
225347
|
|
|
224910
225348
|
// src/service/environment_store.ts
|
|
@@ -225137,7 +225575,7 @@ var __defProp2 = Object.defineProperty;
|
|
|
225137
225575
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
225138
225576
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
225139
225577
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
225140
|
-
var
|
|
225578
|
+
var __esm2 = (fn, res) => function __init() {
|
|
225141
225579
|
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
225142
225580
|
};
|
|
225143
225581
|
var __commonJS2 = (cb, mod2) => function __require2() {
|
|
@@ -225168,13 +225606,13 @@ function toPaths(pathSpec) {
|
|
|
225168
225606
|
return cache.get(pathSpec) || [];
|
|
225169
225607
|
}
|
|
225170
225608
|
var cache;
|
|
225171
|
-
var init_pathspec =
|
|
225609
|
+
var init_pathspec = __esm2({
|
|
225172
225610
|
"src/lib/args/pathspec.ts"() {
|
|
225173
225611
|
cache = /* @__PURE__ */ new WeakMap;
|
|
225174
225612
|
}
|
|
225175
225613
|
});
|
|
225176
225614
|
var GitError;
|
|
225177
|
-
var init_git_error =
|
|
225615
|
+
var init_git_error = __esm2({
|
|
225178
225616
|
"src/lib/errors/git-error.ts"() {
|
|
225179
225617
|
GitError = class extends Error {
|
|
225180
225618
|
constructor(task, message) {
|
|
@@ -225186,7 +225624,7 @@ var init_git_error = __esm({
|
|
|
225186
225624
|
}
|
|
225187
225625
|
});
|
|
225188
225626
|
var GitResponseError;
|
|
225189
|
-
var init_git_response_error =
|
|
225627
|
+
var init_git_response_error = __esm2({
|
|
225190
225628
|
"src/lib/errors/git-response-error.ts"() {
|
|
225191
225629
|
init_git_error();
|
|
225192
225630
|
GitResponseError = class extends GitError {
|
|
@@ -225198,7 +225636,7 @@ var init_git_response_error = __esm({
|
|
|
225198
225636
|
}
|
|
225199
225637
|
});
|
|
225200
225638
|
var TaskConfigurationError;
|
|
225201
|
-
var init_task_configuration_error =
|
|
225639
|
+
var init_task_configuration_error = __esm2({
|
|
225202
225640
|
"src/lib/errors/task-configuration-error.ts"() {
|
|
225203
225641
|
init_git_error();
|
|
225204
225642
|
TaskConfigurationError = class extends GitError {
|
|
@@ -225321,7 +225759,7 @@ function orVoid(input) {
|
|
|
225321
225759
|
var NULL;
|
|
225322
225760
|
var NOOP;
|
|
225323
225761
|
var objectToString;
|
|
225324
|
-
var init_util =
|
|
225762
|
+
var init_util = __esm2({
|
|
225325
225763
|
"src/lib/utils/util.ts"() {
|
|
225326
225764
|
NULL = "\x00";
|
|
225327
225765
|
NOOP = () => {};
|
|
@@ -225349,7 +225787,7 @@ var filterString;
|
|
|
225349
225787
|
var filterStringArray;
|
|
225350
225788
|
var filterStringOrStringArray;
|
|
225351
225789
|
var filterHasLength;
|
|
225352
|
-
var init_argument_filters =
|
|
225790
|
+
var init_argument_filters = __esm2({
|
|
225353
225791
|
"src/lib/utils/argument-filters.ts"() {
|
|
225354
225792
|
init_util();
|
|
225355
225793
|
init_pathspec();
|
|
@@ -225374,7 +225812,7 @@ var init_argument_filters = __esm({
|
|
|
225374
225812
|
}
|
|
225375
225813
|
});
|
|
225376
225814
|
var ExitCodes;
|
|
225377
|
-
var init_exit_codes =
|
|
225815
|
+
var init_exit_codes = __esm2({
|
|
225378
225816
|
"src/lib/utils/exit-codes.ts"() {
|
|
225379
225817
|
ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
|
|
225380
225818
|
ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
|
|
@@ -225386,7 +225824,7 @@ var init_exit_codes = __esm({
|
|
|
225386
225824
|
}
|
|
225387
225825
|
});
|
|
225388
225826
|
var GitOutputStreams;
|
|
225389
|
-
var init_git_output_streams =
|
|
225827
|
+
var init_git_output_streams = __esm2({
|
|
225390
225828
|
"src/lib/utils/git-output-streams.ts"() {
|
|
225391
225829
|
GitOutputStreams = class _GitOutputStreams {
|
|
225392
225830
|
constructor(stdOut, stdErr) {
|
|
@@ -225401,7 +225839,7 @@ var init_git_output_streams = __esm({
|
|
|
225401
225839
|
});
|
|
225402
225840
|
var LineParser;
|
|
225403
225841
|
var RemoteLineParser;
|
|
225404
|
-
var init_line_parser =
|
|
225842
|
+
var init_line_parser = __esm2({
|
|
225405
225843
|
"src/lib/utils/line-parser.ts"() {
|
|
225406
225844
|
LineParser = class {
|
|
225407
225845
|
constructor(regExp, useMatches) {
|
|
@@ -225458,7 +225896,7 @@ function createInstanceConfig(...options) {
|
|
|
225458
225896
|
return config;
|
|
225459
225897
|
}
|
|
225460
225898
|
var defaultOptions2;
|
|
225461
|
-
var init_simple_git_options =
|
|
225899
|
+
var init_simple_git_options = __esm2({
|
|
225462
225900
|
"src/lib/utils/simple-git-options.ts"() {
|
|
225463
225901
|
defaultOptions2 = {
|
|
225464
225902
|
binary: "git",
|
|
@@ -225515,7 +225953,7 @@ function trailingFunctionArgument(args, includeNoop = true) {
|
|
|
225515
225953
|
const callback = asFunction(last(args));
|
|
225516
225954
|
return includeNoop || isUserFunction(callback) ? callback : undefined;
|
|
225517
225955
|
}
|
|
225518
|
-
var init_task_options =
|
|
225956
|
+
var init_task_options = __esm2({
|
|
225519
225957
|
"src/lib/utils/task-options.ts"() {
|
|
225520
225958
|
init_argument_filters();
|
|
225521
225959
|
init_util();
|
|
@@ -225539,7 +225977,7 @@ function parseStringResponse(result, parsers12, texts, trim2 = true) {
|
|
|
225539
225977
|
});
|
|
225540
225978
|
return result;
|
|
225541
225979
|
}
|
|
225542
|
-
var init_task_parser =
|
|
225980
|
+
var init_task_parser = __esm2({
|
|
225543
225981
|
"src/lib/utils/task-parser.ts"() {
|
|
225544
225982
|
init_util();
|
|
225545
225983
|
}
|
|
@@ -225590,7 +226028,7 @@ __export2(utils_exports, {
|
|
|
225590
226028
|
trailingFunctionArgument: () => trailingFunctionArgument,
|
|
225591
226029
|
trailingOptionsArgument: () => trailingOptionsArgument
|
|
225592
226030
|
});
|
|
225593
|
-
var init_utils =
|
|
226031
|
+
var init_utils = __esm2({
|
|
225594
226032
|
"src/lib/utils/index.ts"() {
|
|
225595
226033
|
init_argument_filters();
|
|
225596
226034
|
init_exit_codes();
|
|
@@ -225650,7 +226088,7 @@ function isNotRepoMessage(error) {
|
|
|
225650
226088
|
var CheckRepoActions;
|
|
225651
226089
|
var onError;
|
|
225652
226090
|
var parser;
|
|
225653
|
-
var init_check_is_repo =
|
|
226091
|
+
var init_check_is_repo = __esm2({
|
|
225654
226092
|
"src/lib/tasks/check-is-repo.ts"() {
|
|
225655
226093
|
init_utils();
|
|
225656
226094
|
CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
|
|
@@ -225684,7 +226122,7 @@ var CleanResponse;
|
|
|
225684
226122
|
var removalRegexp;
|
|
225685
226123
|
var dryRunRemovalRegexp;
|
|
225686
226124
|
var isFolderRegexp;
|
|
225687
|
-
var init_CleanSummary =
|
|
226125
|
+
var init_CleanSummary = __esm2({
|
|
225688
226126
|
"src/lib/responses/CleanSummary.ts"() {
|
|
225689
226127
|
init_utils();
|
|
225690
226128
|
CleanResponse = class {
|
|
@@ -225751,7 +226189,7 @@ function isEmptyTask(task) {
|
|
|
225751
226189
|
return task.format === "empty" || !task.commands.length;
|
|
225752
226190
|
}
|
|
225753
226191
|
var EMPTY_COMMANDS;
|
|
225754
|
-
var init_task =
|
|
226192
|
+
var init_task = __esm2({
|
|
225755
226193
|
"src/lib/tasks/task.ts"() {
|
|
225756
226194
|
init_task_configuration_error();
|
|
225757
226195
|
EMPTY_COMMANDS = [];
|
|
@@ -225829,7 +226267,7 @@ var CONFIG_ERROR_MODE_REQUIRED;
|
|
|
225829
226267
|
var CONFIG_ERROR_UNKNOWN_OPTION;
|
|
225830
226268
|
var CleanOptions;
|
|
225831
226269
|
var CleanOptionValues;
|
|
225832
|
-
var init_clean =
|
|
226270
|
+
var init_clean = __esm2({
|
|
225833
226271
|
"src/lib/tasks/clean.ts"() {
|
|
225834
226272
|
init_CleanSummary();
|
|
225835
226273
|
init_utils();
|
|
@@ -225902,7 +226340,7 @@ function* configParser(text, requestedKey = null) {
|
|
|
225902
226340
|
}
|
|
225903
226341
|
}
|
|
225904
226342
|
var ConfigList;
|
|
225905
|
-
var init_ConfigList =
|
|
226343
|
+
var init_ConfigList = __esm2({
|
|
225906
226344
|
"src/lib/responses/ConfigList.ts"() {
|
|
225907
226345
|
init_utils();
|
|
225908
226346
|
ConfigList = class {
|
|
@@ -226000,7 +226438,7 @@ function config_default() {
|
|
|
226000
226438
|
};
|
|
226001
226439
|
}
|
|
226002
226440
|
var GitConfigScope;
|
|
226003
|
-
var init_config =
|
|
226441
|
+
var init_config = __esm2({
|
|
226004
226442
|
"src/lib/tasks/config.ts"() {
|
|
226005
226443
|
init_ConfigList();
|
|
226006
226444
|
init_utils();
|
|
@@ -226018,7 +226456,7 @@ function isDiffNameStatus(input) {
|
|
|
226018
226456
|
}
|
|
226019
226457
|
var DiffNameStatus;
|
|
226020
226458
|
var diffNameStatus;
|
|
226021
|
-
var init_diff_name_status =
|
|
226459
|
+
var init_diff_name_status = __esm2({
|
|
226022
226460
|
"src/lib/tasks/diff-name-status.ts"() {
|
|
226023
226461
|
DiffNameStatus = /* @__PURE__ */ ((DiffNameStatus2) => {
|
|
226024
226462
|
DiffNameStatus2["ADDED"] = "A";
|
|
@@ -226083,7 +226521,7 @@ var disallowedOptions;
|
|
|
226083
226521
|
var Query;
|
|
226084
226522
|
var _a;
|
|
226085
226523
|
var GrepQuery;
|
|
226086
|
-
var init_grep =
|
|
226524
|
+
var init_grep = __esm2({
|
|
226087
226525
|
"src/lib/tasks/grep.ts"() {
|
|
226088
226526
|
init_utils();
|
|
226089
226527
|
init_task();
|
|
@@ -226139,7 +226577,7 @@ function isValidResetMode(mode) {
|
|
|
226139
226577
|
}
|
|
226140
226578
|
var ResetMode;
|
|
226141
226579
|
var ResetModes;
|
|
226142
|
-
var init_reset =
|
|
226580
|
+
var init_reset = __esm2({
|
|
226143
226581
|
"src/lib/tasks/reset.ts"() {
|
|
226144
226582
|
init_task();
|
|
226145
226583
|
ResetMode = /* @__PURE__ */ ((ResetMode2) => {
|
|
@@ -226201,7 +226639,7 @@ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
|
|
|
226201
226639
|
});
|
|
226202
226640
|
}
|
|
226203
226641
|
}
|
|
226204
|
-
var init_git_logger =
|
|
226642
|
+
var init_git_logger = __esm2({
|
|
226205
226643
|
"src/lib/git-logger.ts"() {
|
|
226206
226644
|
init_utils();
|
|
226207
226645
|
import_debug.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
|
|
@@ -226214,7 +226652,7 @@ var init_git_logger = __esm({
|
|
|
226214
226652
|
}
|
|
226215
226653
|
});
|
|
226216
226654
|
var TasksPendingQueue;
|
|
226217
|
-
var init_tasks_pending_queue =
|
|
226655
|
+
var init_tasks_pending_queue = __esm2({
|
|
226218
226656
|
"src/lib/runners/tasks-pending-queue.ts"() {
|
|
226219
226657
|
init_git_error();
|
|
226220
226658
|
init_git_logger();
|
|
@@ -226298,7 +226736,7 @@ function onDataReceived(target, name, logger2, output) {
|
|
|
226298
226736
|
};
|
|
226299
226737
|
}
|
|
226300
226738
|
var GitExecutorChain;
|
|
226301
|
-
var init_git_executor_chain =
|
|
226739
|
+
var init_git_executor_chain = __esm2({
|
|
226302
226740
|
"src/lib/runners/git-executor-chain.ts"() {
|
|
226303
226741
|
init_git_error();
|
|
226304
226742
|
init_task();
|
|
@@ -226463,7 +226901,7 @@ __export2(git_executor_exports, {
|
|
|
226463
226901
|
GitExecutor: () => GitExecutor
|
|
226464
226902
|
});
|
|
226465
226903
|
var GitExecutor;
|
|
226466
|
-
var init_git_executor =
|
|
226904
|
+
var init_git_executor = __esm2({
|
|
226467
226905
|
"src/lib/runners/git-executor.ts"() {
|
|
226468
226906
|
init_git_executor_chain();
|
|
226469
226907
|
GitExecutor = class {
|
|
@@ -226514,7 +226952,7 @@ function addDeprecationNoticeToError(err) {
|
|
|
226514
226952
|
return all3;
|
|
226515
226953
|
}
|
|
226516
226954
|
}
|
|
226517
|
-
var init_task_callback =
|
|
226955
|
+
var init_task_callback = __esm2({
|
|
226518
226956
|
"src/lib/task-callback.ts"() {
|
|
226519
226957
|
init_git_response_error();
|
|
226520
226958
|
init_utils();
|
|
@@ -226528,7 +226966,7 @@ function changeWorkingDirectoryTask(directory, root) {
|
|
|
226528
226966
|
return (root || instance).cwd = directory;
|
|
226529
226967
|
});
|
|
226530
226968
|
}
|
|
226531
|
-
var init_change_working_directory =
|
|
226969
|
+
var init_change_working_directory = __esm2({
|
|
226532
226970
|
"src/lib/tasks/change-working-directory.ts"() {
|
|
226533
226971
|
init_utils();
|
|
226534
226972
|
init_task();
|
|
@@ -226554,7 +226992,7 @@ function checkout_default() {
|
|
|
226554
226992
|
}
|
|
226555
226993
|
};
|
|
226556
226994
|
}
|
|
226557
|
-
var init_checkout =
|
|
226995
|
+
var init_checkout = __esm2({
|
|
226558
226996
|
"src/lib/tasks/checkout.ts"() {
|
|
226559
226997
|
init_utils();
|
|
226560
226998
|
init_task();
|
|
@@ -226586,7 +227024,7 @@ function count_objects_default() {
|
|
|
226586
227024
|
};
|
|
226587
227025
|
}
|
|
226588
227026
|
var parser2;
|
|
226589
|
-
var init_count_objects =
|
|
227027
|
+
var init_count_objects = __esm2({
|
|
226590
227028
|
"src/lib/tasks/count-objects.ts"() {
|
|
226591
227029
|
init_utils();
|
|
226592
227030
|
parser2 = new LineParser(/([a-z-]+): (\d+)$/, (result, [key, value]) => {
|
|
@@ -226612,7 +227050,7 @@ function parseCommitResult(stdOut) {
|
|
|
226612
227050
|
return parseStringResponse(result, parsers, stdOut);
|
|
226613
227051
|
}
|
|
226614
227052
|
var parsers;
|
|
226615
|
-
var init_parse_commit =
|
|
227053
|
+
var init_parse_commit = __esm2({
|
|
226616
227054
|
"src/lib/parsers/parse-commit.ts"() {
|
|
226617
227055
|
init_utils();
|
|
226618
227056
|
parsers = [
|
|
@@ -226676,7 +227114,7 @@ function commit_default() {
|
|
|
226676
227114
|
return !filterStringOrStringArray(message) && configurationErrorTask(`git.commit: requires the commit message to be supplied as a string/string[]`);
|
|
226677
227115
|
}
|
|
226678
227116
|
}
|
|
226679
|
-
var init_commit =
|
|
227117
|
+
var init_commit = __esm2({
|
|
226680
227118
|
"src/lib/tasks/commit.ts"() {
|
|
226681
227119
|
init_parse_commit();
|
|
226682
227120
|
init_utils();
|
|
@@ -226690,7 +227128,7 @@ function first_commit_default() {
|
|
|
226690
227128
|
}
|
|
226691
227129
|
};
|
|
226692
227130
|
}
|
|
226693
|
-
var init_first_commit =
|
|
227131
|
+
var init_first_commit = __esm2({
|
|
226694
227132
|
"src/lib/tasks/first-commit.ts"() {
|
|
226695
227133
|
init_utils();
|
|
226696
227134
|
init_task();
|
|
@@ -226703,7 +227141,7 @@ function hashObjectTask(filePath, write) {
|
|
|
226703
227141
|
}
|
|
226704
227142
|
return straightThroughStringTask(commands, true);
|
|
226705
227143
|
}
|
|
226706
|
-
var init_hash_object =
|
|
227144
|
+
var init_hash_object = __esm2({
|
|
226707
227145
|
"src/lib/tasks/hash-object.ts"() {
|
|
226708
227146
|
init_task();
|
|
226709
227147
|
}
|
|
@@ -226731,7 +227169,7 @@ function parseInit(bare, path3, text) {
|
|
|
226731
227169
|
var InitSummary;
|
|
226732
227170
|
var initResponseRegex;
|
|
226733
227171
|
var reInitResponseRegex;
|
|
226734
|
-
var init_InitSummary =
|
|
227172
|
+
var init_InitSummary = __esm2({
|
|
226735
227173
|
"src/lib/responses/InitSummary.ts"() {
|
|
226736
227174
|
InitSummary = class {
|
|
226737
227175
|
constructor(bare, path3, existing, gitDir) {
|
|
@@ -226762,7 +227200,7 @@ function initTask(bare = false, path3, customArgs) {
|
|
|
226762
227200
|
};
|
|
226763
227201
|
}
|
|
226764
227202
|
var bareCommand;
|
|
226765
|
-
var init_init =
|
|
227203
|
+
var init_init = __esm2({
|
|
226766
227204
|
"src/lib/tasks/init.ts"() {
|
|
226767
227205
|
init_InitSummary();
|
|
226768
227206
|
bareCommand = "--bare";
|
|
@@ -226781,13 +227219,13 @@ function isLogFormat(customArg) {
|
|
|
226781
227219
|
return logFormatRegex.test(customArg);
|
|
226782
227220
|
}
|
|
226783
227221
|
var logFormatRegex;
|
|
226784
|
-
var init_log_format =
|
|
227222
|
+
var init_log_format = __esm2({
|
|
226785
227223
|
"src/lib/args/log-format.ts"() {
|
|
226786
227224
|
logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
|
|
226787
227225
|
}
|
|
226788
227226
|
});
|
|
226789
227227
|
var DiffSummary;
|
|
226790
|
-
var init_DiffSummary =
|
|
227228
|
+
var init_DiffSummary = __esm2({
|
|
226791
227229
|
"src/lib/responses/DiffSummary.ts"() {
|
|
226792
227230
|
DiffSummary = class {
|
|
226793
227231
|
constructor() {
|
|
@@ -226808,7 +227246,7 @@ var numStatParser;
|
|
|
226808
227246
|
var nameOnlyParser;
|
|
226809
227247
|
var nameStatusParser;
|
|
226810
227248
|
var diffSummaryParsers;
|
|
226811
|
-
var init_parse_diff_summary =
|
|
227249
|
+
var init_parse_diff_summary = __esm2({
|
|
226812
227250
|
"src/lib/parsers/parse-diff-summary.ts"() {
|
|
226813
227251
|
init_log_format();
|
|
226814
227252
|
init_DiffSummary();
|
|
@@ -226929,7 +227367,7 @@ var START_BOUNDARY;
|
|
|
226929
227367
|
var COMMIT_BOUNDARY;
|
|
226930
227368
|
var SPLITTER;
|
|
226931
227369
|
var defaultFieldNames;
|
|
226932
|
-
var init_parse_list_log_summary =
|
|
227370
|
+
var init_parse_list_log_summary = __esm2({
|
|
226933
227371
|
"src/lib/parsers/parse-list-log-summary.ts"() {
|
|
226934
227372
|
init_utils();
|
|
226935
227373
|
init_parse_diff_summary();
|
|
@@ -226968,7 +227406,7 @@ function validateLogFormatConfig(customArgs) {
|
|
|
226968
227406
|
return configurationErrorTask(`Summary flag ${flags} parsing is not compatible with null termination option '-z'`);
|
|
226969
227407
|
}
|
|
226970
227408
|
}
|
|
226971
|
-
var init_diff =
|
|
227409
|
+
var init_diff = __esm2({
|
|
226972
227410
|
"src/lib/tasks/diff.ts"() {
|
|
226973
227411
|
init_log_format();
|
|
226974
227412
|
init_parse_diff_summary();
|
|
@@ -227052,7 +227490,7 @@ function log_default() {
|
|
|
227052
227490
|
}
|
|
227053
227491
|
}
|
|
227054
227492
|
var excludeOptions;
|
|
227055
|
-
var init_log =
|
|
227493
|
+
var init_log = __esm2({
|
|
227056
227494
|
"src/lib/tasks/log.ts"() {
|
|
227057
227495
|
init_log_format();
|
|
227058
227496
|
init_pathspec();
|
|
@@ -227080,7 +227518,7 @@ var init_log = __esm({
|
|
|
227080
227518
|
});
|
|
227081
227519
|
var MergeSummaryConflict;
|
|
227082
227520
|
var MergeSummaryDetail;
|
|
227083
|
-
var init_MergeSummary =
|
|
227521
|
+
var init_MergeSummary = __esm2({
|
|
227084
227522
|
"src/lib/responses/MergeSummary.ts"() {
|
|
227085
227523
|
MergeSummaryConflict = class {
|
|
227086
227524
|
constructor(reason, file = null, meta) {
|
|
@@ -227115,7 +227553,7 @@ var init_MergeSummary = __esm({
|
|
|
227115
227553
|
});
|
|
227116
227554
|
var PullSummary;
|
|
227117
227555
|
var PullFailedSummary;
|
|
227118
|
-
var init_PullSummary =
|
|
227556
|
+
var init_PullSummary = __esm2({
|
|
227119
227557
|
"src/lib/responses/PullSummary.ts"() {
|
|
227120
227558
|
PullSummary = class {
|
|
227121
227559
|
constructor() {
|
|
@@ -227172,7 +227610,7 @@ function asObjectCount(source) {
|
|
|
227172
227610
|
};
|
|
227173
227611
|
}
|
|
227174
227612
|
var remoteMessagesObjectParsers;
|
|
227175
|
-
var init_parse_remote_objects =
|
|
227613
|
+
var init_parse_remote_objects = __esm2({
|
|
227176
227614
|
"src/lib/parsers/parse-remote-objects.ts"() {
|
|
227177
227615
|
init_utils();
|
|
227178
227616
|
remoteMessagesObjectParsers = [
|
|
@@ -227200,7 +227638,7 @@ function parseRemoteMessages(_stdOut, stdErr) {
|
|
|
227200
227638
|
}
|
|
227201
227639
|
var parsers2;
|
|
227202
227640
|
var RemoteMessageSummary;
|
|
227203
|
-
var init_parse_remote_messages =
|
|
227641
|
+
var init_parse_remote_messages = __esm2({
|
|
227204
227642
|
"src/lib/parsers/parse-remote-messages.ts"() {
|
|
227205
227643
|
init_utils();
|
|
227206
227644
|
init_parse_remote_objects();
|
|
@@ -227239,7 +227677,7 @@ var parsers3;
|
|
|
227239
227677
|
var errorParsers;
|
|
227240
227678
|
var parsePullDetail;
|
|
227241
227679
|
var parsePullResult;
|
|
227242
|
-
var init_parse_pull =
|
|
227680
|
+
var init_parse_pull = __esm2({
|
|
227243
227681
|
"src/lib/parsers/parse-pull.ts"() {
|
|
227244
227682
|
init_PullSummary();
|
|
227245
227683
|
init_utils();
|
|
@@ -227292,7 +227730,7 @@ var init_parse_pull = __esm({
|
|
|
227292
227730
|
var parsers4;
|
|
227293
227731
|
var parseMergeResult;
|
|
227294
227732
|
var parseMergeDetail;
|
|
227295
|
-
var init_parse_merge =
|
|
227733
|
+
var init_parse_merge = __esm2({
|
|
227296
227734
|
"src/lib/parsers/parse-merge.ts"() {
|
|
227297
227735
|
init_MergeSummary();
|
|
227298
227736
|
init_utils();
|
|
@@ -227338,7 +227776,7 @@ function mergeTask(customArgs) {
|
|
|
227338
227776
|
}
|
|
227339
227777
|
};
|
|
227340
227778
|
}
|
|
227341
|
-
var init_merge =
|
|
227779
|
+
var init_merge = __esm2({
|
|
227342
227780
|
"src/lib/tasks/merge.ts"() {
|
|
227343
227781
|
init_git_response_error();
|
|
227344
227782
|
init_parse_merge();
|
|
@@ -227362,7 +227800,7 @@ function pushResultPushedItem(local, remote, status) {
|
|
|
227362
227800
|
var parsers5;
|
|
227363
227801
|
var parsePushResult;
|
|
227364
227802
|
var parsePushDetail;
|
|
227365
|
-
var init_parse_push =
|
|
227803
|
+
var init_parse_push = __esm2({
|
|
227366
227804
|
"src/lib/parsers/parse-push.ts"() {
|
|
227367
227805
|
init_utils();
|
|
227368
227806
|
init_parse_remote_messages();
|
|
@@ -227439,7 +227877,7 @@ function pushTask(ref = {}, customArgs) {
|
|
|
227439
227877
|
parser: parsePushResult
|
|
227440
227878
|
};
|
|
227441
227879
|
}
|
|
227442
|
-
var init_push =
|
|
227880
|
+
var init_push = __esm2({
|
|
227443
227881
|
"src/lib/tasks/push.ts"() {
|
|
227444
227882
|
init_parse_push();
|
|
227445
227883
|
init_utils();
|
|
@@ -227460,7 +227898,7 @@ function show_default() {
|
|
|
227460
227898
|
}
|
|
227461
227899
|
};
|
|
227462
227900
|
}
|
|
227463
|
-
var init_show =
|
|
227901
|
+
var init_show = __esm2({
|
|
227464
227902
|
"src/lib/tasks/show.ts"() {
|
|
227465
227903
|
init_utils();
|
|
227466
227904
|
init_task();
|
|
@@ -227468,7 +227906,7 @@ var init_show = __esm({
|
|
|
227468
227906
|
});
|
|
227469
227907
|
var fromPathRegex;
|
|
227470
227908
|
var FileStatusSummary;
|
|
227471
|
-
var init_FileStatusSummary =
|
|
227909
|
+
var init_FileStatusSummary = __esm2({
|
|
227472
227910
|
"src/lib/responses/FileStatusSummary.ts"() {
|
|
227473
227911
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
227474
227912
|
FileStatusSummary = class {
|
|
@@ -227522,7 +227960,7 @@ function splitLine(result, lineStr) {
|
|
|
227522
227960
|
var StatusSummary;
|
|
227523
227961
|
var parsers6;
|
|
227524
227962
|
var parseStatusSummary;
|
|
227525
|
-
var init_StatusSummary =
|
|
227963
|
+
var init_StatusSummary = __esm2({
|
|
227526
227964
|
"src/lib/responses/StatusSummary.ts"() {
|
|
227527
227965
|
init_utils();
|
|
227528
227966
|
init_FileStatusSummary();
|
|
@@ -227629,7 +228067,7 @@ function statusTask(customArgs) {
|
|
|
227629
228067
|
};
|
|
227630
228068
|
}
|
|
227631
228069
|
var ignoredOptions;
|
|
227632
|
-
var init_status =
|
|
228070
|
+
var init_status = __esm2({
|
|
227633
228071
|
"src/lib/tasks/status.ts"() {
|
|
227634
228072
|
init_StatusSummary();
|
|
227635
228073
|
ignoredOptions = ["--null", "-z"];
|
|
@@ -227678,7 +228116,7 @@ function versionParser(stdOut) {
|
|
|
227678
228116
|
}
|
|
227679
228117
|
var NOT_INSTALLED;
|
|
227680
228118
|
var parsers7;
|
|
227681
|
-
var init_version =
|
|
228119
|
+
var init_version = __esm2({
|
|
227682
228120
|
"src/lib/tasks/version.ts"() {
|
|
227683
228121
|
init_utils();
|
|
227684
228122
|
NOT_INSTALLED = "installed=false";
|
|
@@ -227697,7 +228135,7 @@ __export2(simple_git_api_exports, {
|
|
|
227697
228135
|
SimpleGitApi: () => SimpleGitApi
|
|
227698
228136
|
});
|
|
227699
228137
|
var SimpleGitApi;
|
|
227700
|
-
var init_simple_git_api =
|
|
228138
|
+
var init_simple_git_api = __esm2({
|
|
227701
228139
|
"src/lib/simple-git-api.ts"() {
|
|
227702
228140
|
init_task_callback();
|
|
227703
228141
|
init_change_working_directory();
|
|
@@ -227788,7 +228226,7 @@ __export2(scheduler_exports, {
|
|
|
227788
228226
|
});
|
|
227789
228227
|
var createScheduledTask;
|
|
227790
228228
|
var Scheduler;
|
|
227791
|
-
var init_scheduler =
|
|
228229
|
+
var init_scheduler = __esm2({
|
|
227792
228230
|
"src/lib/runners/scheduler.ts"() {
|
|
227793
228231
|
init_utils();
|
|
227794
228232
|
init_git_logger();
|
|
@@ -227841,7 +228279,7 @@ __export2(apply_patch_exports, {
|
|
|
227841
228279
|
function applyPatchTask(patches, customArgs) {
|
|
227842
228280
|
return straightThroughStringTask(["apply", ...customArgs, ...patches]);
|
|
227843
228281
|
}
|
|
227844
|
-
var init_apply_patch =
|
|
228282
|
+
var init_apply_patch = __esm2({
|
|
227845
228283
|
"src/lib/tasks/apply-patch.ts"() {
|
|
227846
228284
|
init_task();
|
|
227847
228285
|
}
|
|
@@ -227861,7 +228299,7 @@ function branchDeletionFailure(branch) {
|
|
|
227861
228299
|
};
|
|
227862
228300
|
}
|
|
227863
228301
|
var BranchDeletionBatch;
|
|
227864
|
-
var init_BranchDeleteSummary =
|
|
228302
|
+
var init_BranchDeleteSummary = __esm2({
|
|
227865
228303
|
"src/lib/responses/BranchDeleteSummary.ts"() {
|
|
227866
228304
|
BranchDeletionBatch = class {
|
|
227867
228305
|
constructor() {
|
|
@@ -227882,7 +228320,7 @@ var deleteSuccessRegex;
|
|
|
227882
228320
|
var deleteErrorRegex;
|
|
227883
228321
|
var parsers8;
|
|
227884
228322
|
var parseBranchDeletions;
|
|
227885
|
-
var init_parse_branch_delete =
|
|
228323
|
+
var init_parse_branch_delete = __esm2({
|
|
227886
228324
|
"src/lib/parsers/parse-branch-delete.ts"() {
|
|
227887
228325
|
init_BranchDeleteSummary();
|
|
227888
228326
|
init_utils();
|
|
@@ -227907,7 +228345,7 @@ var init_parse_branch_delete = __esm({
|
|
|
227907
228345
|
}
|
|
227908
228346
|
});
|
|
227909
228347
|
var BranchSummaryResult;
|
|
227910
|
-
var init_BranchSummary =
|
|
228348
|
+
var init_BranchSummary = __esm2({
|
|
227911
228349
|
"src/lib/responses/BranchSummary.ts"() {
|
|
227912
228350
|
BranchSummaryResult = class {
|
|
227913
228351
|
constructor() {
|
|
@@ -227940,7 +228378,7 @@ function parseBranchSummary(stdOut) {
|
|
|
227940
228378
|
return parseStringResponse(new BranchSummaryResult, parsers9, stdOut);
|
|
227941
228379
|
}
|
|
227942
228380
|
var parsers9;
|
|
227943
|
-
var init_parse_branch =
|
|
228381
|
+
var init_parse_branch = __esm2({
|
|
227944
228382
|
"src/lib/parsers/parse-branch.ts"() {
|
|
227945
228383
|
init_BranchSummary();
|
|
227946
228384
|
init_utils();
|
|
@@ -228025,7 +228463,7 @@ function deleteBranchTask(branch, forceDelete = false) {
|
|
|
228025
228463
|
};
|
|
228026
228464
|
return task;
|
|
228027
228465
|
}
|
|
228028
|
-
var init_branch =
|
|
228466
|
+
var init_branch = __esm2({
|
|
228029
228467
|
"src/lib/tasks/branch.ts"() {
|
|
228030
228468
|
init_git_response_error();
|
|
228031
228469
|
init_parse_branch_delete();
|
|
@@ -228034,7 +228472,7 @@ var init_branch = __esm({
|
|
|
228034
228472
|
}
|
|
228035
228473
|
});
|
|
228036
228474
|
var parseCheckIgnore;
|
|
228037
|
-
var init_CheckIgnore =
|
|
228475
|
+
var init_CheckIgnore = __esm2({
|
|
228038
228476
|
"src/lib/responses/CheckIgnore.ts"() {
|
|
228039
228477
|
parseCheckIgnore = (text) => {
|
|
228040
228478
|
return text.split(/\n/g).map((line) => line.trim()).filter((file) => !!file);
|
|
@@ -228052,7 +228490,7 @@ function checkIgnoreTask(paths) {
|
|
|
228052
228490
|
parser: parseCheckIgnore
|
|
228053
228491
|
};
|
|
228054
228492
|
}
|
|
228055
|
-
var init_check_ignore =
|
|
228493
|
+
var init_check_ignore = __esm2({
|
|
228056
228494
|
"src/lib/tasks/check-ignore.ts"() {
|
|
228057
228495
|
init_CheckIgnore();
|
|
228058
228496
|
}
|
|
@@ -228079,7 +228517,7 @@ function cloneMirrorTask(repo, directory, customArgs) {
|
|
|
228079
228517
|
append2(customArgs, "--mirror");
|
|
228080
228518
|
return cloneTask(repo, directory, customArgs);
|
|
228081
228519
|
}
|
|
228082
|
-
var init_clone =
|
|
228520
|
+
var init_clone = __esm2({
|
|
228083
228521
|
"src/lib/tasks/clone.ts"() {
|
|
228084
228522
|
init_task();
|
|
228085
228523
|
init_utils();
|
|
@@ -228097,7 +228535,7 @@ function parseFetchResult(stdOut, stdErr) {
|
|
|
228097
228535
|
return parseStringResponse(result, parsers10, [stdOut, stdErr]);
|
|
228098
228536
|
}
|
|
228099
228537
|
var parsers10;
|
|
228100
|
-
var init_parse_fetch =
|
|
228538
|
+
var init_parse_fetch = __esm2({
|
|
228101
228539
|
"src/lib/parsers/parse-fetch.ts"() {
|
|
228102
228540
|
init_utils();
|
|
228103
228541
|
parsers10 = [
|
|
@@ -228154,7 +228592,7 @@ function fetchTask(remote, branch, customArgs) {
|
|
|
228154
228592
|
parser: parseFetchResult
|
|
228155
228593
|
};
|
|
228156
228594
|
}
|
|
228157
|
-
var init_fetch =
|
|
228595
|
+
var init_fetch = __esm2({
|
|
228158
228596
|
"src/lib/tasks/fetch.ts"() {
|
|
228159
228597
|
init_parse_fetch();
|
|
228160
228598
|
init_task();
|
|
@@ -228164,7 +228602,7 @@ function parseMoveResult(stdOut) {
|
|
|
228164
228602
|
return parseStringResponse({ moves: [] }, parsers11, stdOut);
|
|
228165
228603
|
}
|
|
228166
228604
|
var parsers11;
|
|
228167
|
-
var init_parse_move =
|
|
228605
|
+
var init_parse_move = __esm2({
|
|
228168
228606
|
"src/lib/parsers/parse-move.ts"() {
|
|
228169
228607
|
init_utils();
|
|
228170
228608
|
parsers11 = [
|
|
@@ -228185,7 +228623,7 @@ function moveTask(from, to) {
|
|
|
228185
228623
|
parser: parseMoveResult
|
|
228186
228624
|
};
|
|
228187
228625
|
}
|
|
228188
|
-
var init_move =
|
|
228626
|
+
var init_move = __esm2({
|
|
228189
228627
|
"src/lib/tasks/move.ts"() {
|
|
228190
228628
|
init_parse_move();
|
|
228191
228629
|
init_utils();
|
|
@@ -228215,7 +228653,7 @@ function pullTask(remote, branch, customArgs) {
|
|
|
228215
228653
|
}
|
|
228216
228654
|
};
|
|
228217
228655
|
}
|
|
228218
|
-
var init_pull =
|
|
228656
|
+
var init_pull = __esm2({
|
|
228219
228657
|
"src/lib/tasks/pull.ts"() {
|
|
228220
228658
|
init_git_response_error();
|
|
228221
228659
|
init_parse_pull();
|
|
@@ -228245,7 +228683,7 @@ function parseGetRemotesVerbose(text) {
|
|
|
228245
228683
|
function forEach2(text, handler) {
|
|
228246
228684
|
forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
|
|
228247
228685
|
}
|
|
228248
|
-
var init_GetRemoteSummary =
|
|
228686
|
+
var init_GetRemoteSummary = __esm2({
|
|
228249
228687
|
"src/lib/responses/GetRemoteSummary.ts"() {
|
|
228250
228688
|
init_utils();
|
|
228251
228689
|
}
|
|
@@ -228289,7 +228727,7 @@ function remoteTask(customArgs) {
|
|
|
228289
228727
|
function removeRemoteTask(remoteName) {
|
|
228290
228728
|
return straightThroughStringTask(["remote", "remove", remoteName]);
|
|
228291
228729
|
}
|
|
228292
|
-
var init_remote =
|
|
228730
|
+
var init_remote = __esm2({
|
|
228293
228731
|
"src/lib/tasks/remote.ts"() {
|
|
228294
228732
|
init_GetRemoteSummary();
|
|
228295
228733
|
init_task();
|
|
@@ -228309,7 +228747,7 @@ function stashListTask(opt = {}, customArgs) {
|
|
|
228309
228747
|
parser: parser4
|
|
228310
228748
|
};
|
|
228311
228749
|
}
|
|
228312
|
-
var init_stash_list =
|
|
228750
|
+
var init_stash_list = __esm2({
|
|
228313
228751
|
"src/lib/tasks/stash-list.ts"() {
|
|
228314
228752
|
init_log_format();
|
|
228315
228753
|
init_parse_list_log_summary();
|
|
@@ -228340,7 +228778,7 @@ function subModuleTask(customArgs) {
|
|
|
228340
228778
|
function updateSubModuleTask(customArgs) {
|
|
228341
228779
|
return subModuleTask(["update", ...customArgs]);
|
|
228342
228780
|
}
|
|
228343
|
-
var init_sub_module =
|
|
228781
|
+
var init_sub_module = __esm2({
|
|
228344
228782
|
"src/lib/tasks/sub-module.ts"() {
|
|
228345
228783
|
init_task();
|
|
228346
228784
|
}
|
|
@@ -228367,7 +228805,7 @@ function toNumber(input) {
|
|
|
228367
228805
|
}
|
|
228368
228806
|
var TagList;
|
|
228369
228807
|
var parseTagList;
|
|
228370
|
-
var init_TagList =
|
|
228808
|
+
var init_TagList = __esm2({
|
|
228371
228809
|
"src/lib/responses/TagList.ts"() {
|
|
228372
228810
|
TagList = class {
|
|
228373
228811
|
constructor(all3, latest) {
|
|
@@ -228433,7 +228871,7 @@ function addAnnotatedTagTask(name, tagMessage) {
|
|
|
228433
228871
|
}
|
|
228434
228872
|
};
|
|
228435
228873
|
}
|
|
228436
|
-
var init_tag =
|
|
228874
|
+
var init_tag = __esm2({
|
|
228437
228875
|
"src/lib/tasks/tag.ts"() {
|
|
228438
228876
|
init_TagList();
|
|
228439
228877
|
}
|
|
@@ -229109,6 +229547,8 @@ var esm_default2 = gitInstanceFactory;
|
|
|
229109
229547
|
import { Writable } from "stream";
|
|
229110
229548
|
|
|
229111
229549
|
// src/config.ts
|
|
229550
|
+
init_constants();
|
|
229551
|
+
init_logger();
|
|
229112
229552
|
import fs2 from "fs";
|
|
229113
229553
|
import path3 from "path";
|
|
229114
229554
|
import { fileURLToPath } from "url";
|
|
@@ -229366,7 +229806,12 @@ var getProcessedPublisherConfig = (serverRoot) => {
|
|
|
229366
229806
|
};
|
|
229367
229807
|
};
|
|
229368
229808
|
|
|
229809
|
+
// src/service/environment_store.ts
|
|
229810
|
+
init_constants();
|
|
229811
|
+
init_errors();
|
|
229812
|
+
|
|
229369
229813
|
// src/health.ts
|
|
229814
|
+
init_logger();
|
|
229370
229815
|
var operationalState = "initializing";
|
|
229371
229816
|
var ready = false;
|
|
229372
229817
|
var preGracefulShutdownCompleted = false;
|
|
@@ -229422,6 +229867,11 @@ async function performGracefulShutdownAfterDrain(server, mcpServer, shutdownGrac
|
|
|
229422
229867
|
await shutdownSDK();
|
|
229423
229868
|
logger.info("OpenTelemetry SDK shut down");
|
|
229424
229869
|
} catch (_error) {}
|
|
229870
|
+
try {
|
|
229871
|
+
const { getCompilePool: getCompilePool2 } = await Promise.resolve().then(() => (init_compile_pool(), exports_compile_pool));
|
|
229872
|
+
await getCompilePool2().shutdown();
|
|
229873
|
+
logger.info("Malloy compile worker pool shut down");
|
|
229874
|
+
} catch (_error) {}
|
|
229425
229875
|
if (shutdownGracefulCloseTimeoutSeconds > 0) {
|
|
229426
229876
|
logger.info(`Waiting ${shutdownGracefulCloseTimeoutSeconds} seconds after server close before exit...`);
|
|
229427
229877
|
await new Promise((resolve3) => setTimeout(resolve3, shutdownGracefulCloseTimeoutSeconds * 1000));
|
|
@@ -229463,7 +229913,12 @@ function registerHealthEndpoints(app) {
|
|
|
229463
229913
|
});
|
|
229464
229914
|
}
|
|
229465
229915
|
|
|
229916
|
+
// src/service/environment_store.ts
|
|
229917
|
+
init_logger();
|
|
229918
|
+
|
|
229466
229919
|
// src/storage/StorageManager.ts
|
|
229920
|
+
init_errors();
|
|
229921
|
+
init_logger();
|
|
229467
229922
|
import * as crypto3 from "crypto";
|
|
229468
229923
|
|
|
229469
229924
|
// src/storage/duckdb/DuckDBConnection.ts
|
|
@@ -230270,6 +230725,7 @@ class DuckDBRepository {
|
|
|
230270
230725
|
}
|
|
230271
230726
|
|
|
230272
230727
|
// src/storage/duckdb/schema.ts
|
|
230728
|
+
init_logger();
|
|
230273
230729
|
async function initializeSchema(db, force = false) {
|
|
230274
230730
|
const initialized = await db.isInitialized();
|
|
230275
230731
|
if (initialized && !force) {
|
|
@@ -230398,6 +230854,8 @@ async function dropAllTables(db) {
|
|
|
230398
230854
|
}
|
|
230399
230855
|
|
|
230400
230856
|
// src/storage/ducklake/DuckLakeManifestStore.ts
|
|
230857
|
+
init_logger();
|
|
230858
|
+
|
|
230401
230859
|
class DuckLakeManifestStore {
|
|
230402
230860
|
db;
|
|
230403
230861
|
table;
|
|
@@ -230625,11 +231083,15 @@ class StorageManager {
|
|
|
230625
231083
|
|
|
230626
231084
|
// src/service/environment.ts
|
|
230627
231085
|
import { MalloyError as MalloyError3, Runtime as Runtime2 } from "@malloydata/malloy";
|
|
231086
|
+
init_constants();
|
|
231087
|
+
init_errors();
|
|
231088
|
+
init_logger();
|
|
230628
231089
|
import crypto4 from "crypto";
|
|
230629
231090
|
import * as fs6 from "fs";
|
|
230630
231091
|
import * as path9 from "path";
|
|
230631
231092
|
|
|
230632
231093
|
// src/path_safety.ts
|
|
231094
|
+
init_errors();
|
|
230633
231095
|
import * as path5 from "path";
|
|
230634
231096
|
var SAFE_NAME_RE = /^(?!\.\.?$)(?!\.)[A-Za-z0-9._-]{1,255}$/;
|
|
230635
231097
|
var MAX_MODEL_PATH_LEN = 1024;
|
|
@@ -230684,12 +231146,12 @@ function safeJoinUnderRoot(root, ...segments) {
|
|
|
230684
231146
|
// src/utils.ts
|
|
230685
231147
|
import * as fs3 from "fs";
|
|
230686
231148
|
import * as path6 from "path";
|
|
230687
|
-
import { fileURLToPath as
|
|
231149
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
230688
231150
|
var URL_READER = {
|
|
230689
231151
|
readURL: (url2) => {
|
|
230690
231152
|
let path7 = url2.toString();
|
|
230691
231153
|
if (url2.protocol == "file:") {
|
|
230692
|
-
path7 =
|
|
231154
|
+
path7 = fileURLToPath3(url2);
|
|
230693
231155
|
}
|
|
230694
231156
|
return fs3.promises.readFile(path7, "utf8");
|
|
230695
231157
|
}
|
|
@@ -230699,17 +231161,27 @@ function ignoreDotfiles(file) {
|
|
|
230699
231161
|
}
|
|
230700
231162
|
|
|
230701
231163
|
// src/service/package.ts
|
|
231164
|
+
init_compile_pool();
|
|
231165
|
+
init_constants();
|
|
231166
|
+
init_errors();
|
|
231167
|
+
init_logger();
|
|
230702
231168
|
var import_api3 = __toESM(require_src(), 1);
|
|
230703
231169
|
var import_recursive_readdir = __toESM(require_recursive_readdir(), 1);
|
|
230704
231170
|
import * as fs5 from "fs/promises";
|
|
230705
231171
|
import * as path8 from "path";
|
|
231172
|
+
import { DuckDBConnection as DuckDBConnection3 } from "@malloydata/db-duckdb";
|
|
231173
|
+
import"@malloydata/db-duckdb/native";
|
|
230706
231174
|
import {
|
|
231175
|
+
ConnectionRuntime,
|
|
230707
231176
|
contextOverlay as contextOverlay2,
|
|
231177
|
+
EmptyURLReader,
|
|
230708
231178
|
FixedConnectionMap as FixedConnectionMap2,
|
|
230709
231179
|
MalloyConfig as MalloyConfig3
|
|
230710
231180
|
} from "@malloydata/malloy";
|
|
230711
231181
|
|
|
230712
231182
|
// src/service/model.ts
|
|
231183
|
+
init_compile_pool();
|
|
231184
|
+
init_constants();
|
|
230713
231185
|
var import_api2 = __toESM(require_src(), 1);
|
|
230714
231186
|
import {
|
|
230715
231187
|
API,
|
|
@@ -230729,6 +231201,7 @@ import { createRequire as createRequire2 } from "module";
|
|
|
230729
231201
|
import * as path7 from "path";
|
|
230730
231202
|
|
|
230731
231203
|
// src/data_styles.ts
|
|
231204
|
+
init_logger();
|
|
230732
231205
|
function compileDataStyles(styles) {
|
|
230733
231206
|
try {
|
|
230734
231207
|
return JSON.parse(styles);
|
|
@@ -230775,6 +231248,10 @@ class HackyDataStylesAccumulator {
|
|
|
230775
231248
|
}
|
|
230776
231249
|
}
|
|
230777
231250
|
|
|
231251
|
+
// src/service/model.ts
|
|
231252
|
+
init_errors();
|
|
231253
|
+
init_logger();
|
|
231254
|
+
|
|
230778
231255
|
// src/service/filter.ts
|
|
230779
231256
|
var VALID_FILTER_TYPES = new Set([
|
|
230780
231257
|
"equal",
|
|
@@ -230983,6 +231460,8 @@ class Model {
|
|
|
230983
231460
|
dataStyles;
|
|
230984
231461
|
modelType;
|
|
230985
231462
|
modelMaterializer;
|
|
231463
|
+
materializerBuilder;
|
|
231464
|
+
materializerBuildPromise;
|
|
230986
231465
|
modelDef;
|
|
230987
231466
|
modelInfo;
|
|
230988
231467
|
sources;
|
|
@@ -230992,18 +231471,20 @@ class Model {
|
|
|
230992
231471
|
compilationError;
|
|
230993
231472
|
filterMap;
|
|
230994
231473
|
givens;
|
|
231474
|
+
cachedStandardModel;
|
|
230995
231475
|
meter = import_api2.metrics.getMeter("publisher");
|
|
230996
231476
|
queryExecutionHistogram = this.meter.createHistogram("malloy_model_query_duration", {
|
|
230997
231477
|
description: "How long it takes to execute a Malloy model query",
|
|
230998
231478
|
unit: "ms"
|
|
230999
231479
|
});
|
|
231000
|
-
constructor(packageName, modelPath, dataStyles, modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, compilationError, filterMap, givens) {
|
|
231480
|
+
constructor(packageName, modelPath, dataStyles, modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, compilationError, filterMap, givens, materializerBuilder) {
|
|
231001
231481
|
this.packageName = packageName;
|
|
231002
231482
|
this.modelPath = modelPath;
|
|
231003
231483
|
this.dataStyles = dataStyles;
|
|
231004
231484
|
this.modelType = modelType;
|
|
231005
231485
|
this.modelDef = modelDef;
|
|
231006
231486
|
this.modelMaterializer = modelMaterializer;
|
|
231487
|
+
this.materializerBuilder = materializerBuilder;
|
|
231007
231488
|
this.sources = sources;
|
|
231008
231489
|
this.queries = queries;
|
|
231009
231490
|
this.sourceInfos = sourceInfos;
|
|
@@ -231013,6 +231494,20 @@ class Model {
|
|
|
231013
231494
|
this.givens = givens;
|
|
231014
231495
|
this.modelInfo = this.modelDef ? modelDefToModelInfo(this.modelDef) : undefined;
|
|
231015
231496
|
}
|
|
231497
|
+
async ensureMaterializer() {
|
|
231498
|
+
if (this.modelMaterializer)
|
|
231499
|
+
return this.modelMaterializer;
|
|
231500
|
+
if (!this.materializerBuilder) {
|
|
231501
|
+
throw new BadRequestError("Model has no queryable entities.");
|
|
231502
|
+
}
|
|
231503
|
+
if (!this.materializerBuildPromise) {
|
|
231504
|
+
this.materializerBuildPromise = this.materializerBuilder().then((mm) => {
|
|
231505
|
+
this.modelMaterializer = mm;
|
|
231506
|
+
return mm;
|
|
231507
|
+
});
|
|
231508
|
+
}
|
|
231509
|
+
return this.materializerBuildPromise;
|
|
231510
|
+
}
|
|
231016
231511
|
getFilters(sourceName) {
|
|
231017
231512
|
return this.filterMap.get(sourceName) ?? [];
|
|
231018
231513
|
}
|
|
@@ -231024,6 +231519,40 @@ class Model {
|
|
|
231024
231519
|
return runMatch?.[1] ?? arrowMatch?.[1];
|
|
231025
231520
|
}
|
|
231026
231521
|
static async create(packageName, packagePath, modelPath, malloyConfig, options) {
|
|
231522
|
+
const pool = getCompilePool();
|
|
231523
|
+
if (pool.enabled && modelPath.endsWith(MODEL_FILE_SUFFIX)) {
|
|
231524
|
+
try {
|
|
231525
|
+
return await Model.createViaWorker(packageName, packagePath, modelPath, malloyConfig, pool, options);
|
|
231526
|
+
} catch (poolError) {
|
|
231527
|
+
if (poolError instanceof ModelCompilationError || poolError instanceof MalloyError2) {
|
|
231528
|
+
return Model.makeErrorModel(packageName, modelPath, poolError instanceof MalloyError2 ? new ModelCompilationError(poolError) : poolError);
|
|
231529
|
+
}
|
|
231530
|
+
logger.warn("Compile worker failed; falling back to in-process compile", { packageName, modelPath, error: poolError });
|
|
231531
|
+
}
|
|
231532
|
+
}
|
|
231533
|
+
return Model.createInProcess(packageName, packagePath, modelPath, malloyConfig, options);
|
|
231534
|
+
}
|
|
231535
|
+
static async createViaWorker(packageName, packagePath, modelPath, malloyConfig, pool, options) {
|
|
231536
|
+
const resolvedConfig = Model.toMalloyConfig(malloyConfig);
|
|
231537
|
+
const outcome = await pool.compile({
|
|
231538
|
+
packagePath,
|
|
231539
|
+
modelPath,
|
|
231540
|
+
malloyConfig: resolvedConfig,
|
|
231541
|
+
defaultConnectionName: "duckdb",
|
|
231542
|
+
urlReader: URL_READER,
|
|
231543
|
+
buildManifest: options?.buildManifest
|
|
231544
|
+
});
|
|
231545
|
+
const materializerBuilder = async () => {
|
|
231546
|
+
const { runtime, modelURL, importBaseURL } = await Model.getModelRuntime(packagePath, modelPath, malloyConfig, options);
|
|
231547
|
+
return Model.getStandardModelMaterializer(runtime, importBaseURL, modelURL, modelPath);
|
|
231548
|
+
};
|
|
231549
|
+
return new Model(packageName, modelPath, {}, "model", undefined, outcome.modelDef, outcome.sources, outcome.queries, outcome.sourceInfos.length > 0 ? outcome.sourceInfos : undefined, undefined, undefined, outcome.filterMap, outcome.givens, materializerBuilder);
|
|
231550
|
+
}
|
|
231551
|
+
static makeErrorModel(packageName, modelPath, error) {
|
|
231552
|
+
const isNotebook = modelPath.endsWith(NOTEBOOK_FILE_SUFFIX);
|
|
231553
|
+
return new Model(packageName, modelPath, {}, isNotebook ? "notebook" : "model", undefined, undefined, undefined, undefined, undefined, undefined, error);
|
|
231554
|
+
}
|
|
231555
|
+
static async createInProcess(packageName, packagePath, modelPath, malloyConfig, options) {
|
|
231027
231556
|
const { runtime, modelURL, importBaseURL, dataStyles, modelType } = await Model.getModelRuntime(packagePath, modelPath, malloyConfig, options);
|
|
231028
231557
|
try {
|
|
231029
231558
|
const { modelMaterializer, runnableNotebookCells } = await Model.getModelMaterializer(runtime, importBaseURL, modelURL, modelPath);
|
|
@@ -231134,8 +231663,18 @@ class Model {
|
|
|
231134
231663
|
throw new BadRequestError(`Model compilation failed: ${this.compilationError.message}`);
|
|
231135
231664
|
}
|
|
231136
231665
|
let runnable;
|
|
231137
|
-
if (!this.
|
|
231666
|
+
if (!this.modelDef || !this.modelInfo)
|
|
231138
231667
|
throw new BadRequestError("Model has no queryable entities.");
|
|
231668
|
+
let materializer;
|
|
231669
|
+
try {
|
|
231670
|
+
materializer = await this.ensureMaterializer();
|
|
231671
|
+
} catch (error) {
|
|
231672
|
+
if (error instanceof BadRequestError)
|
|
231673
|
+
throw error;
|
|
231674
|
+
if (error instanceof MalloyError2)
|
|
231675
|
+
throw error;
|
|
231676
|
+
throw new BadRequestError(error instanceof Error ? `Failed to prepare model: ${error.message}` : "Failed to prepare model.");
|
|
231677
|
+
}
|
|
231139
231678
|
try {
|
|
231140
231679
|
let queryString;
|
|
231141
231680
|
if (!sourceName && !queryName && query) {
|
|
@@ -231166,7 +231705,7 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231166
231705
|
}
|
|
231167
231706
|
}
|
|
231168
231707
|
}
|
|
231169
|
-
runnable =
|
|
231708
|
+
runnable = materializer.loadQuery(queryString);
|
|
231170
231709
|
} catch (error) {
|
|
231171
231710
|
if (error instanceof BadRequestError) {
|
|
231172
231711
|
throw error;
|
|
@@ -231238,7 +231777,9 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231238
231777
|
};
|
|
231239
231778
|
}
|
|
231240
231779
|
getStandardModel() {
|
|
231241
|
-
|
|
231780
|
+
if (this.cachedStandardModel)
|
|
231781
|
+
return this.cachedStandardModel;
|
|
231782
|
+
const compiled = {
|
|
231242
231783
|
type: "source",
|
|
231243
231784
|
packageName: this.packageName,
|
|
231244
231785
|
modelPath: this.modelPath,
|
|
@@ -231251,6 +231792,8 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231251
231792
|
queries: this.queries,
|
|
231252
231793
|
givens: this.givens
|
|
231253
231794
|
};
|
|
231795
|
+
this.cachedStandardModel = compiled;
|
|
231796
|
+
return compiled;
|
|
231254
231797
|
}
|
|
231255
231798
|
async getNotebookModel() {
|
|
231256
231799
|
const notebookCells = this.runnableNotebookCells.map((cell) => {
|
|
@@ -231576,167 +232119,6 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231576
232119
|
}
|
|
231577
232120
|
}
|
|
231578
232121
|
|
|
231579
|
-
// src/service/schema_worker_pool.ts
|
|
231580
|
-
import { Worker } from "worker_threads";
|
|
231581
|
-
var DEFAULT_POOL_SIZE = 2;
|
|
231582
|
-
|
|
231583
|
-
class SchemaWorkerPool {
|
|
231584
|
-
workerUrl;
|
|
231585
|
-
size;
|
|
231586
|
-
workers = [];
|
|
231587
|
-
queue = [];
|
|
231588
|
-
inFlight = new Map;
|
|
231589
|
-
workerCurrentId = new Map;
|
|
231590
|
-
nextId = 1;
|
|
231591
|
-
stopped = false;
|
|
231592
|
-
constructor(workerUrl, size = DEFAULT_POOL_SIZE) {
|
|
231593
|
-
this.workerUrl = workerUrl;
|
|
231594
|
-
this.size = size;
|
|
231595
|
-
}
|
|
231596
|
-
start() {
|
|
231597
|
-
if (this.workers.length > 0)
|
|
231598
|
-
return;
|
|
231599
|
-
for (let i = 0;i < this.size; i++) {
|
|
231600
|
-
this.workers.push(this.spawn(i));
|
|
231601
|
-
}
|
|
231602
|
-
logger.info(`SchemaWorkerPool started (size=${this.size})`);
|
|
231603
|
-
}
|
|
231604
|
-
async stop() {
|
|
231605
|
-
this.stopped = true;
|
|
231606
|
-
const shutdownError = new Error("SchemaWorkerPool stopped");
|
|
231607
|
-
for (const req of this.queue.splice(0))
|
|
231608
|
-
req.reject(shutdownError);
|
|
231609
|
-
for (const req of this.inFlight.values())
|
|
231610
|
-
req.reject(shutdownError);
|
|
231611
|
-
this.inFlight.clear();
|
|
231612
|
-
await Promise.all(this.workers.map(async (slot) => {
|
|
231613
|
-
try {
|
|
231614
|
-
await slot.worker.terminate();
|
|
231615
|
-
} catch {}
|
|
231616
|
-
}));
|
|
231617
|
-
this.workers.length = 0;
|
|
231618
|
-
}
|
|
231619
|
-
submit(packagePath, databasePath) {
|
|
231620
|
-
if (this.stopped) {
|
|
231621
|
-
return Promise.reject(new Error("SchemaWorkerPool stopped"));
|
|
231622
|
-
}
|
|
231623
|
-
if (this.workers.length === 0) {
|
|
231624
|
-
return Promise.reject(new Error("SchemaWorkerPool.submit called before start()"));
|
|
231625
|
-
}
|
|
231626
|
-
return new Promise((resolve4, reject) => {
|
|
231627
|
-
const req = {
|
|
231628
|
-
id: this.nextId++,
|
|
231629
|
-
packagePath,
|
|
231630
|
-
databasePath,
|
|
231631
|
-
resolve: resolve4,
|
|
231632
|
-
reject
|
|
231633
|
-
};
|
|
231634
|
-
this.queue.push(req);
|
|
231635
|
-
this.drain();
|
|
231636
|
-
});
|
|
231637
|
-
}
|
|
231638
|
-
drain() {
|
|
231639
|
-
for (let i = 0;i < this.workers.length; i++) {
|
|
231640
|
-
if (this.queue.length === 0)
|
|
231641
|
-
return;
|
|
231642
|
-
const slot = this.workers[i];
|
|
231643
|
-
if (slot.busy)
|
|
231644
|
-
continue;
|
|
231645
|
-
const req = this.queue.shift();
|
|
231646
|
-
slot.busy = true;
|
|
231647
|
-
this.inFlight.set(req.id, req);
|
|
231648
|
-
this.workerCurrentId.set(i, req.id);
|
|
231649
|
-
slot.worker.postMessage({
|
|
231650
|
-
id: req.id,
|
|
231651
|
-
packagePath: req.packagePath,
|
|
231652
|
-
databasePath: req.databasePath
|
|
231653
|
-
});
|
|
231654
|
-
}
|
|
231655
|
-
}
|
|
231656
|
-
spawn(index) {
|
|
231657
|
-
const worker = new Worker(this.workerUrl);
|
|
231658
|
-
const slot = { worker, busy: false };
|
|
231659
|
-
worker.on("message", (msg) => {
|
|
231660
|
-
const req = this.inFlight.get(msg.id);
|
|
231661
|
-
if (!req) {
|
|
231662
|
-
logger.warn("SchemaWorkerPool: response for unknown request", {
|
|
231663
|
-
id: msg.id,
|
|
231664
|
-
workerIndex: index
|
|
231665
|
-
});
|
|
231666
|
-
return;
|
|
231667
|
-
}
|
|
231668
|
-
this.inFlight.delete(msg.id);
|
|
231669
|
-
this.workerCurrentId.delete(index);
|
|
231670
|
-
slot.busy = false;
|
|
231671
|
-
if (msg.ok && msg.result) {
|
|
231672
|
-
req.resolve(msg.result);
|
|
231673
|
-
} else {
|
|
231674
|
-
const err = new Error(msg.error?.message ?? "Unknown error");
|
|
231675
|
-
if (msg.error?.stack)
|
|
231676
|
-
err.stack = msg.error.stack;
|
|
231677
|
-
req.reject(err);
|
|
231678
|
-
}
|
|
231679
|
-
this.drain();
|
|
231680
|
-
});
|
|
231681
|
-
worker.on("error", (err) => {
|
|
231682
|
-
const inFlightId = this.workerCurrentId.get(index);
|
|
231683
|
-
if (inFlightId !== undefined) {
|
|
231684
|
-
const req = this.inFlight.get(inFlightId);
|
|
231685
|
-
if (req) {
|
|
231686
|
-
this.inFlight.delete(inFlightId);
|
|
231687
|
-
req.reject(err);
|
|
231688
|
-
}
|
|
231689
|
-
this.workerCurrentId.delete(index);
|
|
231690
|
-
}
|
|
231691
|
-
logger.error("SchemaWorkerPool: worker errored, respawning", {
|
|
231692
|
-
workerIndex: index,
|
|
231693
|
-
error: err
|
|
231694
|
-
});
|
|
231695
|
-
if (!this.stopped) {
|
|
231696
|
-
this.workers[index] = this.spawn(index);
|
|
231697
|
-
this.drain();
|
|
231698
|
-
}
|
|
231699
|
-
});
|
|
231700
|
-
worker.on("exit", (code) => {
|
|
231701
|
-
if (this.stopped)
|
|
231702
|
-
return;
|
|
231703
|
-
if (code !== 0) {
|
|
231704
|
-
logger.warn("SchemaWorkerPool: worker exited unexpectedly", {
|
|
231705
|
-
workerIndex: index,
|
|
231706
|
-
code
|
|
231707
|
-
});
|
|
231708
|
-
const inFlightId = this.workerCurrentId.get(index);
|
|
231709
|
-
if (inFlightId !== undefined) {
|
|
231710
|
-
const req = this.inFlight.get(inFlightId);
|
|
231711
|
-
if (req) {
|
|
231712
|
-
this.inFlight.delete(inFlightId);
|
|
231713
|
-
req.reject(new Error(`SchemaWorker exited with code ${code}`));
|
|
231714
|
-
}
|
|
231715
|
-
this.workerCurrentId.delete(index);
|
|
231716
|
-
}
|
|
231717
|
-
this.workers[index] = this.spawn(index);
|
|
231718
|
-
this.drain();
|
|
231719
|
-
}
|
|
231720
|
-
});
|
|
231721
|
-
return slot;
|
|
231722
|
-
}
|
|
231723
|
-
}
|
|
231724
|
-
var singleton = null;
|
|
231725
|
-
function getSchemaWorkerPool() {
|
|
231726
|
-
if (!singleton) {
|
|
231727
|
-
const url2 = resolveWorkerUrl();
|
|
231728
|
-
const size = Number(process.env.PUBLISHER_SCHEMA_WORKER_POOL_SIZE) || 2;
|
|
231729
|
-
singleton = new SchemaWorkerPool(url2, size);
|
|
231730
|
-
singleton.start();
|
|
231731
|
-
}
|
|
231732
|
-
return singleton;
|
|
231733
|
-
}
|
|
231734
|
-
function resolveWorkerUrl() {
|
|
231735
|
-
const base = new URL(import.meta.url);
|
|
231736
|
-
const isBundled = base.pathname.endsWith(".mjs");
|
|
231737
|
-
return new URL(isBundled ? "./service/schema_worker.mjs" : "./schema_worker.ts", base);
|
|
231738
|
-
}
|
|
231739
|
-
|
|
231740
232122
|
// src/service/package.ts
|
|
231741
232123
|
var ENABLE_LIST_MODEL_COMPILATION = true;
|
|
231742
232124
|
|
|
@@ -231770,7 +232152,6 @@ class Package {
|
|
|
231770
232152
|
packageName,
|
|
231771
232153
|
duration: formatDuration(manifestValidationTime - startTime)
|
|
231772
232154
|
});
|
|
231773
|
-
let packageMalloyConfig;
|
|
231774
232155
|
try {
|
|
231775
232156
|
const packageConfig = await Package.readPackageConfig(packagePath);
|
|
231776
232157
|
const packageConfigTime = performance.now();
|
|
@@ -231831,13 +232212,6 @@ class Package {
|
|
|
231831
232212
|
malloy_package_name: packageName,
|
|
231832
232213
|
status: "error"
|
|
231833
232214
|
});
|
|
231834
|
-
if (packageMalloyConfig) {
|
|
231835
|
-
try {
|
|
231836
|
-
await packageMalloyConfig.shutdown("close");
|
|
231837
|
-
} catch (releaseError) {
|
|
231838
|
-
logger.warn(`Failed to release package-local DuckDB for ${packageName}`, { error: releaseError });
|
|
231839
|
-
}
|
|
231840
|
-
}
|
|
231841
232215
|
try {
|
|
231842
232216
|
await fs5.rm(packagePath, {
|
|
231843
232217
|
recursive: true,
|
|
@@ -231999,29 +232373,14 @@ class Package {
|
|
|
231999
232373
|
};
|
|
232000
232374
|
}
|
|
232001
232375
|
static async readDatabases(packagePath) {
|
|
232002
|
-
|
|
232003
|
-
|
|
232004
|
-
return
|
|
232005
|
-
|
|
232006
|
-
|
|
232007
|
-
|
|
232008
|
-
|
|
232009
|
-
|
|
232010
|
-
if (outcome.status === "fulfilled") {
|
|
232011
|
-
results.push({
|
|
232012
|
-
path: databasePaths[i],
|
|
232013
|
-
info: outcome.value,
|
|
232014
|
-
type: "embedded"
|
|
232015
|
-
});
|
|
232016
|
-
} else {
|
|
232017
|
-
logger.warn("Schema introspection failed for database", {
|
|
232018
|
-
packagePath,
|
|
232019
|
-
databasePath: databasePaths[i],
|
|
232020
|
-
error: outcome.reason
|
|
232021
|
-
});
|
|
232022
|
-
}
|
|
232023
|
-
}
|
|
232024
|
-
return results;
|
|
232376
|
+
return await Promise.all((await Package.getDatabasePaths(packagePath)).map(async (databasePath) => {
|
|
232377
|
+
const databaseInfo = await Package.getDatabaseInfo(packagePath, databasePath);
|
|
232378
|
+
return {
|
|
232379
|
+
path: databasePath,
|
|
232380
|
+
info: databaseInfo,
|
|
232381
|
+
type: "embedded"
|
|
232382
|
+
};
|
|
232383
|
+
}));
|
|
232025
232384
|
}
|
|
232026
232385
|
static async getDatabasePaths(packagePath) {
|
|
232027
232386
|
const files = await import_recursive_readdir.default(packagePath, [ignoreDotfiles]);
|
|
@@ -232029,6 +232388,60 @@ class Package {
|
|
|
232029
232388
|
return path8.relative(packagePath, fullPath).replace(/\\/g, "/");
|
|
232030
232389
|
}).filter((modelPath) => modelPath.endsWith(".parquet") || modelPath.endsWith(".csv"));
|
|
232031
232390
|
}
|
|
232391
|
+
static async getDatabaseInfo(packagePath, databasePath) {
|
|
232392
|
+
const fullPath = path8.join(packagePath, databasePath);
|
|
232393
|
+
const normalizedPath = fullPath.replace(/\\/g, "/");
|
|
232394
|
+
const conn = new DuckDBConnection3("duckdb");
|
|
232395
|
+
const pool = getCompilePool();
|
|
232396
|
+
let schema;
|
|
232397
|
+
if (pool.enabled) {
|
|
232398
|
+
schema = await Package.getSchemaViaPool(pool, packagePath, normalizedPath, conn);
|
|
232399
|
+
} else {
|
|
232400
|
+
schema = await Package.getSchemaInProcess(normalizedPath, conn);
|
|
232401
|
+
}
|
|
232402
|
+
const escapedPath = normalizedPath.replace(/'/g, "''");
|
|
232403
|
+
const sqlResult = await conn.runSQL(`SELECT count(*)::BIGINT AS row_count FROM '${escapedPath}'`);
|
|
232404
|
+
const firstRow = sqlResult.rows[0];
|
|
232405
|
+
const rowCount = Number(firstRow.row_count ?? 0);
|
|
232406
|
+
return { name: databasePath, rowCount, columns: schema };
|
|
232407
|
+
}
|
|
232408
|
+
static async getSchemaInProcess(normalizedPath, conn) {
|
|
232409
|
+
const runtime = new ConnectionRuntime({
|
|
232410
|
+
urlReader: new EmptyURLReader,
|
|
232411
|
+
connections: [conn]
|
|
232412
|
+
});
|
|
232413
|
+
const model = runtime.loadModel(`source: temp is duckdb.table('${normalizedPath}')`);
|
|
232414
|
+
const modelDef = await model.getModel();
|
|
232415
|
+
const fields = modelDef._modelDef.contents["temp"].fields;
|
|
232416
|
+
return fields.map((field) => {
|
|
232417
|
+
return { type: field.type, name: field.name };
|
|
232418
|
+
});
|
|
232419
|
+
}
|
|
232420
|
+
static async getSchemaViaPool(pool, packagePath, normalizedPath, conn) {
|
|
232421
|
+
const malloyConfig = new MalloyConfig3({ connections: {} }, { config: contextOverlay2({ rootDirectory: packagePath }) });
|
|
232422
|
+
malloyConfig.wrapConnections(() => ({
|
|
232423
|
+
lookupConnection: async (_name) => conn
|
|
232424
|
+
}));
|
|
232425
|
+
try {
|
|
232426
|
+
const outcome = await pool.compileInline({
|
|
232427
|
+
packagePath,
|
|
232428
|
+
source: `source: temp is duckdb.table('${normalizedPath}')`,
|
|
232429
|
+
malloyConfig,
|
|
232430
|
+
defaultConnectionName: "duckdb"
|
|
232431
|
+
});
|
|
232432
|
+
const modelDef = outcome.modelDef;
|
|
232433
|
+
const fields = modelDef.contents["temp"].fields;
|
|
232434
|
+
return fields.map((field) => {
|
|
232435
|
+
return { type: field.type, name: field.name };
|
|
232436
|
+
});
|
|
232437
|
+
} catch (error) {
|
|
232438
|
+
if (error instanceof Error && !/timed out|exited unexpectedly|shutting down/i.test(error.message)) {
|
|
232439
|
+
throw error;
|
|
232440
|
+
}
|
|
232441
|
+
logger.warn("Compile worker failed for database probe; falling back to in-process", { normalizedPath, error: error.message });
|
|
232442
|
+
return Package.getSchemaInProcess(normalizedPath, conn);
|
|
232443
|
+
}
|
|
232444
|
+
}
|
|
232032
232445
|
setName(name) {
|
|
232033
232446
|
this.packageName = name;
|
|
232034
232447
|
}
|
|
@@ -232997,10 +233410,6 @@ class EnvironmentStore {
|
|
|
232997
233410
|
return Promise.all(Array.from(this.environments.values()).map((environment) => environment.serialize()));
|
|
232998
233411
|
}
|
|
232999
233412
|
async getStatus() {
|
|
233000
|
-
const memoryGovernorStatus = this.memoryGovernor?.getStatus() ?? null;
|
|
233001
|
-
logger.info("Memory governor status", {
|
|
233002
|
-
memoryGovernor: memoryGovernorStatus
|
|
233003
|
-
});
|
|
233004
233413
|
const status = {
|
|
233005
233414
|
timestamp: Date.now(),
|
|
233006
233415
|
environments: [],
|
|
@@ -233644,7 +234053,12 @@ class WatchModeController {
|
|
|
233644
234053
|
};
|
|
233645
234054
|
}
|
|
233646
234055
|
|
|
234056
|
+
// src/server.ts
|
|
234057
|
+
init_errors();
|
|
234058
|
+
init_logger();
|
|
234059
|
+
|
|
233647
234060
|
// src/service/resolve_environment.ts
|
|
234061
|
+
init_errors();
|
|
233648
234062
|
async function resolveEnvironmentId(repository, environmentName) {
|
|
233649
234063
|
const dbEnvironment = await repository.getEnvironmentByName(environmentName);
|
|
233650
234064
|
if (!dbEnvironment) {
|
|
@@ -233676,6 +234090,8 @@ class ManifestController {
|
|
|
233676
234090
|
}
|
|
233677
234091
|
|
|
233678
234092
|
// src/controller/materialization.controller.ts
|
|
234093
|
+
init_errors();
|
|
234094
|
+
|
|
233679
234095
|
class MaterializationController {
|
|
233680
234096
|
materializationService;
|
|
233681
234097
|
constructor(materializationService) {
|
|
@@ -236362,6 +236778,12 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
236362
236778
|
}
|
|
236363
236779
|
};
|
|
236364
236780
|
|
|
236781
|
+
// src/mcp/server.ts
|
|
236782
|
+
init_logger();
|
|
236783
|
+
|
|
236784
|
+
// src/mcp/prompts/prompt_service.ts
|
|
236785
|
+
init_logger();
|
|
236786
|
+
|
|
236365
236787
|
// src/mcp/prompts/handlers.ts
|
|
236366
236788
|
var import_handlebars = __toESM(require_lib8(), 1);
|
|
236367
236789
|
|
|
@@ -236556,6 +236978,9 @@ function registerPromptCapability(mcpServer, environmentStore) {
|
|
|
236556
236978
|
logger.info(`[MCP Init] Finished registering prompts. Registered: ${registeredCount}`, { duration: endTime - startTime });
|
|
236557
236979
|
}
|
|
236558
236980
|
|
|
236981
|
+
// src/mcp/resources/environment_resource.ts
|
|
236982
|
+
init_logger();
|
|
236983
|
+
|
|
236559
236984
|
// src/mcp/error_messages.ts
|
|
236560
236985
|
function getNotFoundError(resourceUriOrContext) {
|
|
236561
236986
|
const baseMessage = `Resource not found: ${resourceUriOrContext}`;
|
|
@@ -236645,6 +237070,9 @@ function getMalloyErrorDetails(operation, modelIdentifier, error) {
|
|
|
236645
237070
|
}
|
|
236646
237071
|
|
|
236647
237072
|
// src/mcp/handler_utils.ts
|
|
237073
|
+
init_errors();
|
|
237074
|
+
init_logger();
|
|
237075
|
+
|
|
236648
237076
|
class McpGetResourceError extends Error {
|
|
236649
237077
|
details;
|
|
236650
237078
|
constructor(details) {
|
|
@@ -236857,6 +237285,7 @@ function registerEnvironmentResource(mcpServer, environmentStore) {
|
|
|
236857
237285
|
}
|
|
236858
237286
|
|
|
236859
237287
|
// src/mcp/resources/model_resource.ts
|
|
237288
|
+
init_errors();
|
|
236860
237289
|
function registerModelResource(mcpServer, environmentStore) {
|
|
236861
237290
|
mcpServer.resource("model", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "model", async ({
|
|
236862
237291
|
environmentName,
|
|
@@ -236916,6 +237345,8 @@ function registerModelResource(mcpServer, environmentStore) {
|
|
|
236916
237345
|
}
|
|
236917
237346
|
|
|
236918
237347
|
// src/mcp/resources/notebook_resource.ts
|
|
237348
|
+
init_errors();
|
|
237349
|
+
init_logger();
|
|
236919
237350
|
function registerNotebookResource(mcpServer, environmentStore) {
|
|
236920
237351
|
mcpServer.resource("notebook", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/notebooks/{notebookName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "notebook", async ({ environmentName, packageName, notebookName }, uri2) => {
|
|
236921
237352
|
if (typeof environmentName !== "string" || typeof packageName !== "string" || typeof notebookName !== "string") {
|
|
@@ -236955,6 +237386,8 @@ function registerNotebookResource(mcpServer, environmentStore) {
|
|
|
236955
237386
|
}
|
|
236956
237387
|
|
|
236957
237388
|
// src/mcp/resources/package_resource.ts
|
|
237389
|
+
init_errors();
|
|
237390
|
+
init_logger();
|
|
236958
237391
|
async function handleGetPackageContents(uri, params, environmentStore) {
|
|
236959
237392
|
try {
|
|
236960
237393
|
const { environmentName, packageName } = params;
|
|
@@ -237147,6 +237580,8 @@ function registerPackageResource(mcpServer, environmentStore) {
|
|
|
237147
237580
|
}
|
|
237148
237581
|
|
|
237149
237582
|
// src/mcp/resources/query_resource.ts
|
|
237583
|
+
init_errors();
|
|
237584
|
+
init_logger();
|
|
237150
237585
|
function registerQueryResource(mcpServer, environmentStore) {
|
|
237151
237586
|
mcpServer.resource("query", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/queries/{queryName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "query", async ({
|
|
237152
237587
|
environmentName,
|
|
@@ -237189,6 +237624,8 @@ function registerQueryResource(mcpServer, environmentStore) {
|
|
|
237189
237624
|
}
|
|
237190
237625
|
|
|
237191
237626
|
// src/mcp/resources/source_resource.ts
|
|
237627
|
+
init_errors();
|
|
237628
|
+
init_logger();
|
|
237192
237629
|
function registerSourceResource(mcpServer, environmentStore) {
|
|
237193
237630
|
mcpServer.resource("source", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/sources/{sourceName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "source", async ({
|
|
237194
237631
|
environmentName,
|
|
@@ -237234,6 +237671,8 @@ function registerSourceResource(mcpServer, environmentStore) {
|
|
|
237234
237671
|
}
|
|
237235
237672
|
|
|
237236
237673
|
// src/mcp/resources/view_resource.ts
|
|
237674
|
+
init_errors();
|
|
237675
|
+
init_logger();
|
|
237237
237676
|
function registerViewResource(mcpServer, environmentStore) {
|
|
237238
237677
|
mcpServer.resource("view", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/sources/{sourceName}/views/{viewName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "view", async ({
|
|
237239
237678
|
environmentName,
|
|
@@ -237431,6 +237870,9 @@ function registerTools(mcpServer, environmentStore) {
|
|
|
237431
237870
|
});
|
|
237432
237871
|
}
|
|
237433
237872
|
|
|
237873
|
+
// src/mcp/tools/execute_query_tool.ts
|
|
237874
|
+
init_logger();
|
|
237875
|
+
|
|
237434
237876
|
// src/mcp/mcp_constants.ts
|
|
237435
237877
|
var MCP_ERROR_MESSAGES = {
|
|
237436
237878
|
MISSING_REQUIRED_PARAMS: "Either 'query' or both 'sourceName' and 'queryName' must be provided",
|
|
@@ -237637,6 +238079,8 @@ function initializeMcpServer(environmentStore) {
|
|
|
237637
238079
|
}
|
|
237638
238080
|
|
|
237639
238081
|
// src/server-old.ts
|
|
238082
|
+
init_errors();
|
|
238083
|
+
init_logger();
|
|
237640
238084
|
var import_body_parser = __toESM(require_body_parser(), 1);
|
|
237641
238085
|
var LEGACY_API_PREFIX = "/api/v0";
|
|
237642
238086
|
function remapMaterializationResponse(mat) {
|
|
@@ -238212,6 +238656,8 @@ function registerLegacyRoutes(app, controllers) {
|
|
|
238212
238656
|
}
|
|
238213
238657
|
|
|
238214
238658
|
// src/service/manifest_service.ts
|
|
238659
|
+
init_logger();
|
|
238660
|
+
|
|
238215
238661
|
class ManifestService {
|
|
238216
238662
|
environmentStore;
|
|
238217
238663
|
constructor(environmentStore) {
|
|
@@ -238247,9 +238693,12 @@ class ManifestService {
|
|
|
238247
238693
|
}
|
|
238248
238694
|
|
|
238249
238695
|
// src/service/materialization_service.ts
|
|
238696
|
+
init_errors();
|
|
238697
|
+
init_logger();
|
|
238250
238698
|
import { Manifest } from "@malloydata/malloy";
|
|
238251
238699
|
|
|
238252
238700
|
// src/service/materialized_table_gc.ts
|
|
238701
|
+
init_logger();
|
|
238253
238702
|
import {
|
|
238254
238703
|
DatabricksDialect,
|
|
238255
238704
|
DuckDBDialect,
|
|
@@ -238851,6 +239300,7 @@ class MaterializationService {
|
|
|
238851
239300
|
}
|
|
238852
239301
|
|
|
238853
239302
|
// src/service/package_memory_governor.ts
|
|
239303
|
+
init_logger();
|
|
238854
239304
|
var import_api4 = __toESM(require_src(), 1);
|
|
238855
239305
|
var DEFAULT_RSS_SAMPLER = () => process.memoryUsage().rss;
|
|
238856
239306
|
|
|
@@ -238951,118 +239401,6 @@ class PackageMemoryGovernor {
|
|
|
238951
239401
|
}
|
|
238952
239402
|
}
|
|
238953
239403
|
|
|
238954
|
-
// src/service/process_stats_reporter.ts
|
|
238955
|
-
import * as fs8 from "fs";
|
|
238956
|
-
var DEFAULT_INTERVAL_MS = 30000;
|
|
238957
|
-
function readLinuxProcStatus() {
|
|
238958
|
-
try {
|
|
238959
|
-
const raw = fs8.readFileSync("/proc/self/status", "utf8");
|
|
238960
|
-
const out = {};
|
|
238961
|
-
for (const line of raw.split(`
|
|
238962
|
-
`)) {
|
|
238963
|
-
const [keyRaw, valueRaw] = line.split(":");
|
|
238964
|
-
if (!keyRaw || !valueRaw)
|
|
238965
|
-
continue;
|
|
238966
|
-
const key = keyRaw.trim();
|
|
238967
|
-
const value = valueRaw.trim();
|
|
238968
|
-
switch (key) {
|
|
238969
|
-
case "Threads":
|
|
238970
|
-
out.threads = Number(value);
|
|
238971
|
-
break;
|
|
238972
|
-
case "VmRSS":
|
|
238973
|
-
out.vmRssBytes = kBToBytes(value);
|
|
238974
|
-
break;
|
|
238975
|
-
case "VmSize":
|
|
238976
|
-
out.vmSizeBytes = kBToBytes(value);
|
|
238977
|
-
break;
|
|
238978
|
-
case "VmPeak":
|
|
238979
|
-
out.vmPeakBytes = kBToBytes(value);
|
|
238980
|
-
break;
|
|
238981
|
-
case "VmData":
|
|
238982
|
-
out.vmDataBytes = kBToBytes(value);
|
|
238983
|
-
break;
|
|
238984
|
-
case "voluntary_ctxt_switches":
|
|
238985
|
-
out.voluntaryCtxSwitches = Number(value);
|
|
238986
|
-
break;
|
|
238987
|
-
case "nonvoluntary_ctxt_switches":
|
|
238988
|
-
out.nonvoluntaryCtxSwitches = Number(value);
|
|
238989
|
-
break;
|
|
238990
|
-
}
|
|
238991
|
-
}
|
|
238992
|
-
return out;
|
|
238993
|
-
} catch {
|
|
238994
|
-
return null;
|
|
238995
|
-
}
|
|
238996
|
-
}
|
|
238997
|
-
function kBToBytes(value) {
|
|
238998
|
-
const num = Number(value.replace(/\s*kB$/, ""));
|
|
238999
|
-
if (!Number.isFinite(num))
|
|
239000
|
-
return;
|
|
239001
|
-
return num * 1024;
|
|
239002
|
-
}
|
|
239003
|
-
async function readBunJscStats() {
|
|
239004
|
-
if (typeof globalThis.Bun === "undefined") {
|
|
239005
|
-
return null;
|
|
239006
|
-
}
|
|
239007
|
-
try {
|
|
239008
|
-
const jsc = await import("bun:jsc");
|
|
239009
|
-
const heap = jsc.heapStats?.();
|
|
239010
|
-
const mem = jsc.memoryUsage?.();
|
|
239011
|
-
if (!heap && !mem)
|
|
239012
|
-
return null;
|
|
239013
|
-
return { ...heap ?? {}, ...mem ?? {} };
|
|
239014
|
-
} catch {
|
|
239015
|
-
return null;
|
|
239016
|
-
}
|
|
239017
|
-
}
|
|
239018
|
-
|
|
239019
|
-
class ProcessStatsReporter {
|
|
239020
|
-
timer = null;
|
|
239021
|
-
intervalMs;
|
|
239022
|
-
memoryGovernor;
|
|
239023
|
-
constructor(memoryGovernor, intervalMs = DEFAULT_INTERVAL_MS) {
|
|
239024
|
-
this.memoryGovernor = memoryGovernor;
|
|
239025
|
-
this.intervalMs = intervalMs;
|
|
239026
|
-
}
|
|
239027
|
-
start() {
|
|
239028
|
-
if (this.timer !== null)
|
|
239029
|
-
return;
|
|
239030
|
-
this.tick();
|
|
239031
|
-
this.timer = setInterval(() => void this.tick(), this.intervalMs);
|
|
239032
|
-
this.timer.unref?.();
|
|
239033
|
-
logger.info(`ProcessStatsReporter started (intervalMs=${this.intervalMs})`);
|
|
239034
|
-
}
|
|
239035
|
-
stop() {
|
|
239036
|
-
if (this.timer !== null) {
|
|
239037
|
-
clearInterval(this.timer);
|
|
239038
|
-
this.timer = null;
|
|
239039
|
-
}
|
|
239040
|
-
}
|
|
239041
|
-
async tick() {
|
|
239042
|
-
try {
|
|
239043
|
-
const mem = process.memoryUsage();
|
|
239044
|
-
const proc = process.platform === "linux" ? readLinuxProcStatus() : null;
|
|
239045
|
-
const bun = await readBunJscStats();
|
|
239046
|
-
const governor = this.memoryGovernor?.getStatus() ?? null;
|
|
239047
|
-
logger.info("process stats", {
|
|
239048
|
-
uptimeSeconds: Math.round(process.uptime()),
|
|
239049
|
-
nodeMemory: {
|
|
239050
|
-
rssBytes: mem.rss,
|
|
239051
|
-
heapTotalBytes: mem.heapTotal,
|
|
239052
|
-
heapUsedBytes: mem.heapUsed,
|
|
239053
|
-
externalBytes: mem.external,
|
|
239054
|
-
arrayBuffersBytes: mem.arrayBuffers
|
|
239055
|
-
},
|
|
239056
|
-
linux: proc,
|
|
239057
|
-
bunJsc: bun,
|
|
239058
|
-
memoryGovernor: governor
|
|
239059
|
-
});
|
|
239060
|
-
} catch (err) {
|
|
239061
|
-
logger.warn("ProcessStatsReporter tick failed", { error: err });
|
|
239062
|
-
}
|
|
239063
|
-
}
|
|
239064
|
-
}
|
|
239065
|
-
|
|
239066
239404
|
// src/server.ts
|
|
239067
239405
|
function normalizeQueryArray(value) {
|
|
239068
239406
|
if (value === undefined || value === null)
|
|
@@ -239131,7 +239469,7 @@ var MCP_PORT = Number(process.env.MCP_PORT || 4040);
|
|
|
239131
239469
|
var MCP_ENDPOINT = "/mcp";
|
|
239132
239470
|
var SHUTDOWN_DRAIN_DURATION_SECONDS = Number(process.env.SHUTDOWN_DRAIN_DURATION_SECONDS || 0);
|
|
239133
239471
|
var SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS = Number(process.env.SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS || 0);
|
|
239134
|
-
var __filename_esm =
|
|
239472
|
+
var __filename_esm = fileURLToPath4(import.meta.url);
|
|
239135
239473
|
var ROOT = path12.join(path12.dirname(__filename_esm), "app");
|
|
239136
239474
|
var SERVER_ROOT = path12.resolve(process.cwd(), process.env.SERVER_ROOT || ".");
|
|
239137
239475
|
var API_PREFIX2 = "/api/v0";
|
|
@@ -239148,8 +239486,6 @@ var memoryGovernorConfig = getMemoryGovernorConfig();
|
|
|
239148
239486
|
var memoryGovernor = memoryGovernorConfig ? new PackageMemoryGovernor(memoryGovernorConfig) : null;
|
|
239149
239487
|
memoryGovernor?.start();
|
|
239150
239488
|
environmentStore.setMemoryGovernor(memoryGovernor);
|
|
239151
|
-
var processStatsReporter = new ProcessStatsReporter(memoryGovernor);
|
|
239152
|
-
processStatsReporter.start();
|
|
239153
239489
|
var packageController = new PackageController(environmentStore, manifestService);
|
|
239154
239490
|
var databaseController = new DatabaseController(environmentStore);
|
|
239155
239491
|
var queryController = new QueryController(environmentStore);
|