@malloy-publisher/server 0.0.198-dev1 → 0.0.198-dev2
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 +12 -22
- package/dist/instrumentation.mjs +57 -36
- package/dist/server.mjs +650 -926
- package/dist/service/schema_worker.mjs +61 -0
- package/package.json +1 -1
- package/src/health.ts +0 -13
- package/src/instrumentation.ts +50 -0
- package/src/server.ts +5 -0
- package/src/service/environment_store.ts +9 -0
- package/src/service/model.ts +3 -226
- package/src/service/package.spec.ts +11 -7
- package/src/service/package.ts +49 -53
- package/src/service/process_stats_reporter.ts +169 -0
- package/src/service/schema_worker.ts +123 -0
- package/src/service/schema_worker_pool.ts +278 -0
- package/tests/integration/concurrent_environment/concurrent_environment.integration.spec.ts +235 -0
- package/dist/compile_worker.mjs +0 -628
- package/src/compile/compile_pool.spec.ts +0 -227
- package/src/compile/compile_pool.ts +0 -729
- package/src/compile/compile_worker.ts +0 -683
- package/src/compile/protocol.ts +0 -251
- package/src/service/model_worker_path.spec.ts +0 -125
package/dist/server.mjs
CHANGED
|
@@ -44,7 +44,6 @@ 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);
|
|
48
47
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
49
48
|
|
|
50
49
|
// ../../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
@@ -115088,91 +115087,6 @@ var require_winston = __commonJS((exports) => {
|
|
|
115088
115087
|
warn.forProperties(exports, "deprecated", ["emitErrs", "levelLength"]);
|
|
115089
115088
|
});
|
|
115090
115089
|
|
|
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
|
-
|
|
115176
115090
|
// ../../node_modules/bytes/index.js
|
|
115177
115091
|
var require_bytes = __commonJS((exports, module) => {
|
|
115178
115092
|
/*!
|
|
@@ -147314,132 +147228,6 @@ var require_dist4 = __commonJS((exports) => {
|
|
|
147314
147228
|
__exportStar(require_legacy2(), exports);
|
|
147315
147229
|
});
|
|
147316
147230
|
|
|
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
|
-
|
|
147443
147231
|
// ../../node_modules/delayed-stream/lib/delayed_stream.js
|
|
147444
147232
|
var require_delayed_stream = __commonJS((exports, module) => {
|
|
147445
147233
|
var Stream = __require("stream").Stream;
|
|
@@ -199368,441 +199156,6 @@ var require_dist12 = __commonJS((exports) => {
|
|
|
199368
199156
|
exports.default = deferred;
|
|
199369
199157
|
});
|
|
199370
199158
|
|
|
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
|
-
if (!this.enabled) {
|
|
199422
|
-
throw new Error("CompileWorkerPool.compile called while disabled (MALLOY_COMPILE_WORKERS=0)");
|
|
199423
|
-
}
|
|
199424
|
-
if (this.shuttingDown) {
|
|
199425
|
-
throw new Error("CompileWorkerPool is shutting down");
|
|
199426
|
-
}
|
|
199427
|
-
const worker = await this.acquireWorker();
|
|
199428
|
-
this.nextJobId += 1;
|
|
199429
|
-
const jobId = `job-${this.nextJobId}`;
|
|
199430
|
-
return new Promise((resolve3, reject) => {
|
|
199431
|
-
const timeout = setTimeout(() => {
|
|
199432
|
-
this.failJob(jobId, new Error(`Compile job timed out after ${COMPILE_JOB_TIMEOUT_MS}ms (model=${request.modelPath})`));
|
|
199433
|
-
}, COMPILE_JOB_TIMEOUT_MS);
|
|
199434
|
-
this.jobs.set(jobId, {
|
|
199435
|
-
jobId,
|
|
199436
|
-
connections: request.malloyConfig.connections,
|
|
199437
|
-
urlReader: request.urlReader ?? defaultUrlReader,
|
|
199438
|
-
resolve: (result) => {
|
|
199439
|
-
clearTimeout(timeout);
|
|
199440
|
-
resolve3(adaptResult(result));
|
|
199441
|
-
},
|
|
199442
|
-
reject: (err) => {
|
|
199443
|
-
clearTimeout(timeout);
|
|
199444
|
-
reject(err);
|
|
199445
|
-
},
|
|
199446
|
-
timeout
|
|
199447
|
-
});
|
|
199448
|
-
worker.inFlight.add(jobId);
|
|
199449
|
-
const message = {
|
|
199450
|
-
type: "compile",
|
|
199451
|
-
requestId: jobId,
|
|
199452
|
-
packagePath: request.packagePath,
|
|
199453
|
-
modelPath: request.modelPath,
|
|
199454
|
-
defaultConnectionName: request.defaultConnectionName,
|
|
199455
|
-
buildManifest: request.buildManifest
|
|
199456
|
-
};
|
|
199457
|
-
worker.worker.postMessage(message);
|
|
199458
|
-
});
|
|
199459
|
-
}
|
|
199460
|
-
async shutdown() {
|
|
199461
|
-
if (this.shuttingDown)
|
|
199462
|
-
return;
|
|
199463
|
-
this.shuttingDown = true;
|
|
199464
|
-
const exits = this.workers.map((pw) => new Promise((resolve3) => {
|
|
199465
|
-
if (pw.exited) {
|
|
199466
|
-
resolve3();
|
|
199467
|
-
return;
|
|
199468
|
-
}
|
|
199469
|
-
pw.worker.once("exit", () => resolve3());
|
|
199470
|
-
const msg = { type: "shutdown" };
|
|
199471
|
-
pw.worker.postMessage(msg);
|
|
199472
|
-
setTimeout(() => {
|
|
199473
|
-
if (!pw.exited) {
|
|
199474
|
-
pw.worker.terminate().finally(() => resolve3());
|
|
199475
|
-
}
|
|
199476
|
-
}, 1e4);
|
|
199477
|
-
}));
|
|
199478
|
-
await Promise.all(exits);
|
|
199479
|
-
}
|
|
199480
|
-
async acquireWorker() {
|
|
199481
|
-
this.workers.splice(0, this.workers.length, ...this.workers.filter((w) => !w.exited));
|
|
199482
|
-
if (this.workers.length < this.maxWorkers) {
|
|
199483
|
-
const pw = this.spawnWorker();
|
|
199484
|
-
this.workers.push(pw);
|
|
199485
|
-
await pw.ready;
|
|
199486
|
-
return pw;
|
|
199487
|
-
}
|
|
199488
|
-
const alive = this.workers.filter((w) => !w.exited);
|
|
199489
|
-
let best = alive[0];
|
|
199490
|
-
for (const candidate of alive) {
|
|
199491
|
-
if (candidate.inFlight.size < best.inFlight.size) {
|
|
199492
|
-
best = candidate;
|
|
199493
|
-
}
|
|
199494
|
-
}
|
|
199495
|
-
await best.ready;
|
|
199496
|
-
return best;
|
|
199497
|
-
}
|
|
199498
|
-
spawnWorker() {
|
|
199499
|
-
this.nextWorkerId += 1;
|
|
199500
|
-
const id = this.nextWorkerId;
|
|
199501
|
-
logger.info(`CompileWorkerPool: spawning worker #${id} (script=${this.workerScript.toString()})`);
|
|
199502
|
-
const worker = new Worker(this.workerScript, {
|
|
199503
|
-
name: `malloy-compile-worker-${id}`
|
|
199504
|
-
});
|
|
199505
|
-
let readyResolve;
|
|
199506
|
-
const ready = new Promise((r) => readyResolve = r);
|
|
199507
|
-
const pw = {
|
|
199508
|
-
id,
|
|
199509
|
-
worker,
|
|
199510
|
-
ready,
|
|
199511
|
-
inFlight: new Set,
|
|
199512
|
-
exited: false
|
|
199513
|
-
};
|
|
199514
|
-
worker.on("message", (msg) => {
|
|
199515
|
-
this.handleWorkerMessage(pw, msg, readyResolve);
|
|
199516
|
-
});
|
|
199517
|
-
worker.on("error", (err) => {
|
|
199518
|
-
logger.error(`CompileWorkerPool: worker #${id} errored`, {
|
|
199519
|
-
error: err
|
|
199520
|
-
});
|
|
199521
|
-
});
|
|
199522
|
-
worker.on("exit", (code) => {
|
|
199523
|
-
pw.exited = true;
|
|
199524
|
-
logger.warn(`CompileWorkerPool: worker #${id} exited (code=${code}, inFlight=${pw.inFlight.size})`);
|
|
199525
|
-
for (const jobId of pw.inFlight) {
|
|
199526
|
-
this.failJob(jobId, new Error(`Compile worker #${id} exited unexpectedly (code=${code})`));
|
|
199527
|
-
}
|
|
199528
|
-
pw.inFlight.clear();
|
|
199529
|
-
});
|
|
199530
|
-
return pw;
|
|
199531
|
-
}
|
|
199532
|
-
handleWorkerMessage(pw, msg, markReady) {
|
|
199533
|
-
switch (msg.type) {
|
|
199534
|
-
case "ready":
|
|
199535
|
-
markReady();
|
|
199536
|
-
return;
|
|
199537
|
-
case "compile-result":
|
|
199538
|
-
this.completeJob(pw, msg);
|
|
199539
|
-
return;
|
|
199540
|
-
case "compile-error":
|
|
199541
|
-
this.errorJob(pw, msg);
|
|
199542
|
-
return;
|
|
199543
|
-
case "connection-metadata":
|
|
199544
|
-
this.handleConnectionMetadata(pw, msg);
|
|
199545
|
-
return;
|
|
199546
|
-
case "schema-for-tables":
|
|
199547
|
-
this.handleSchemaForTables(pw, msg);
|
|
199548
|
-
return;
|
|
199549
|
-
case "schema-for-sql":
|
|
199550
|
-
this.handleSchemaForSql(pw, msg);
|
|
199551
|
-
return;
|
|
199552
|
-
case "read-url":
|
|
199553
|
-
this.handleReadUrl(pw, msg);
|
|
199554
|
-
return;
|
|
199555
|
-
default: {
|
|
199556
|
-
const exhaustive = msg;
|
|
199557
|
-
return;
|
|
199558
|
-
}
|
|
199559
|
-
}
|
|
199560
|
-
}
|
|
199561
|
-
async handleConnectionMetadata(pw, msg) {
|
|
199562
|
-
const ctx = this.jobs.get(msg.jobId);
|
|
199563
|
-
const reply = (response) => {
|
|
199564
|
-
pw.worker.postMessage(response);
|
|
199565
|
-
};
|
|
199566
|
-
if (!ctx) {
|
|
199567
|
-
reply({
|
|
199568
|
-
type: "rpc-error",
|
|
199569
|
-
requestId: msg.requestId,
|
|
199570
|
-
ok: false,
|
|
199571
|
-
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199572
|
-
});
|
|
199573
|
-
return;
|
|
199574
|
-
}
|
|
199575
|
-
try {
|
|
199576
|
-
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199577
|
-
reply({
|
|
199578
|
-
type: "connection-metadata-response",
|
|
199579
|
-
requestId: msg.requestId,
|
|
199580
|
-
ok: true,
|
|
199581
|
-
metadata: {
|
|
199582
|
-
name: msg.connectionName,
|
|
199583
|
-
dialectName: conn.dialectName,
|
|
199584
|
-
digest: typeof conn.getDigest === "function" ? conn.getDigest() : msg.connectionName
|
|
199585
|
-
}
|
|
199586
|
-
});
|
|
199587
|
-
} catch (error) {
|
|
199588
|
-
reply({
|
|
199589
|
-
type: "rpc-error",
|
|
199590
|
-
requestId: msg.requestId,
|
|
199591
|
-
ok: false,
|
|
199592
|
-
error: serializeError(error)
|
|
199593
|
-
});
|
|
199594
|
-
}
|
|
199595
|
-
}
|
|
199596
|
-
completeJob(pw, msg) {
|
|
199597
|
-
const ctx = this.jobs.get(msg.requestId);
|
|
199598
|
-
if (!ctx)
|
|
199599
|
-
return;
|
|
199600
|
-
this.jobs.delete(msg.requestId);
|
|
199601
|
-
pw.inFlight.delete(msg.requestId);
|
|
199602
|
-
ctx.resolve(msg);
|
|
199603
|
-
}
|
|
199604
|
-
errorJob(pw, msg) {
|
|
199605
|
-
const ctx = this.jobs.get(msg.requestId);
|
|
199606
|
-
if (!ctx)
|
|
199607
|
-
return;
|
|
199608
|
-
this.jobs.delete(msg.requestId);
|
|
199609
|
-
pw.inFlight.delete(msg.requestId);
|
|
199610
|
-
ctx.reject(deserializeError(msg.error));
|
|
199611
|
-
}
|
|
199612
|
-
failJob(jobId, error) {
|
|
199613
|
-
const ctx = this.jobs.get(jobId);
|
|
199614
|
-
if (!ctx)
|
|
199615
|
-
return;
|
|
199616
|
-
this.jobs.delete(jobId);
|
|
199617
|
-
ctx.reject(error);
|
|
199618
|
-
}
|
|
199619
|
-
async handleSchemaForTables(pw, msg) {
|
|
199620
|
-
const ctx = this.jobs.get(msg.jobId);
|
|
199621
|
-
const reply = (response) => {
|
|
199622
|
-
pw.worker.postMessage(response);
|
|
199623
|
-
};
|
|
199624
|
-
if (!ctx) {
|
|
199625
|
-
reply({
|
|
199626
|
-
type: "rpc-error",
|
|
199627
|
-
requestId: msg.requestId,
|
|
199628
|
-
ok: false,
|
|
199629
|
-
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199630
|
-
});
|
|
199631
|
-
return;
|
|
199632
|
-
}
|
|
199633
|
-
try {
|
|
199634
|
-
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199635
|
-
const result = await conn.fetchSchemaForTables(msg.tables, buildFetchOptions(msg.options));
|
|
199636
|
-
reply({
|
|
199637
|
-
type: "schema-for-tables-response",
|
|
199638
|
-
requestId: msg.requestId,
|
|
199639
|
-
ok: true,
|
|
199640
|
-
schemas: result.schemas,
|
|
199641
|
-
errors: result.errors
|
|
199642
|
-
});
|
|
199643
|
-
} catch (error) {
|
|
199644
|
-
reply({
|
|
199645
|
-
type: "rpc-error",
|
|
199646
|
-
requestId: msg.requestId,
|
|
199647
|
-
ok: false,
|
|
199648
|
-
error: serializeError(error)
|
|
199649
|
-
});
|
|
199650
|
-
}
|
|
199651
|
-
}
|
|
199652
|
-
async handleSchemaForSql(pw, msg) {
|
|
199653
|
-
const ctx = this.jobs.get(msg.jobId);
|
|
199654
|
-
const reply = (response) => {
|
|
199655
|
-
pw.worker.postMessage(response);
|
|
199656
|
-
};
|
|
199657
|
-
if (!ctx) {
|
|
199658
|
-
reply({
|
|
199659
|
-
type: "rpc-error",
|
|
199660
|
-
requestId: msg.requestId,
|
|
199661
|
-
ok: false,
|
|
199662
|
-
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199663
|
-
});
|
|
199664
|
-
return;
|
|
199665
|
-
}
|
|
199666
|
-
try {
|
|
199667
|
-
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199668
|
-
const result = await conn.fetchSchemaForSQLStruct(msg.sentence, buildFetchOptions(msg.options));
|
|
199669
|
-
if (result.error !== undefined) {
|
|
199670
|
-
reply({
|
|
199671
|
-
type: "schema-for-sql-response",
|
|
199672
|
-
requestId: msg.requestId,
|
|
199673
|
-
ok: true,
|
|
199674
|
-
error: result.error
|
|
199675
|
-
});
|
|
199676
|
-
} else {
|
|
199677
|
-
reply({
|
|
199678
|
-
type: "schema-for-sql-response",
|
|
199679
|
-
requestId: msg.requestId,
|
|
199680
|
-
ok: true,
|
|
199681
|
-
structDef: result.structDef
|
|
199682
|
-
});
|
|
199683
|
-
}
|
|
199684
|
-
} catch (error) {
|
|
199685
|
-
reply({
|
|
199686
|
-
type: "rpc-error",
|
|
199687
|
-
requestId: msg.requestId,
|
|
199688
|
-
ok: false,
|
|
199689
|
-
error: serializeError(error)
|
|
199690
|
-
});
|
|
199691
|
-
}
|
|
199692
|
-
}
|
|
199693
|
-
async handleReadUrl(pw, msg) {
|
|
199694
|
-
const ctx = this.jobs.get(msg.jobId);
|
|
199695
|
-
const reply = (response) => {
|
|
199696
|
-
pw.worker.postMessage(response);
|
|
199697
|
-
};
|
|
199698
|
-
if (!ctx) {
|
|
199699
|
-
reply({
|
|
199700
|
-
type: "rpc-error",
|
|
199701
|
-
requestId: msg.requestId,
|
|
199702
|
-
ok: false,
|
|
199703
|
-
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199704
|
-
});
|
|
199705
|
-
return;
|
|
199706
|
-
}
|
|
199707
|
-
try {
|
|
199708
|
-
const raw = await ctx.urlReader.readURL(new URL(msg.url));
|
|
199709
|
-
const contents = typeof raw === "string" ? raw : raw.contents;
|
|
199710
|
-
reply({
|
|
199711
|
-
type: "read-url-response",
|
|
199712
|
-
requestId: msg.requestId,
|
|
199713
|
-
ok: true,
|
|
199714
|
-
contents
|
|
199715
|
-
});
|
|
199716
|
-
} catch (error) {
|
|
199717
|
-
reply({
|
|
199718
|
-
type: "rpc-error",
|
|
199719
|
-
requestId: msg.requestId,
|
|
199720
|
-
ok: false,
|
|
199721
|
-
error: serializeError(error)
|
|
199722
|
-
});
|
|
199723
|
-
}
|
|
199724
|
-
}
|
|
199725
|
-
}
|
|
199726
|
-
function buildFetchOptions(options) {
|
|
199727
|
-
const out = {};
|
|
199728
|
-
if (options.refreshTimestamp !== undefined) {
|
|
199729
|
-
out.refreshTimestamp = options.refreshTimestamp;
|
|
199730
|
-
}
|
|
199731
|
-
if (options.modelAnnotation !== undefined) {
|
|
199732
|
-
out.modelAnnotation = options.modelAnnotation;
|
|
199733
|
-
}
|
|
199734
|
-
return out;
|
|
199735
|
-
}
|
|
199736
|
-
function adaptResult(result) {
|
|
199737
|
-
return {
|
|
199738
|
-
modelDef: result.modelDef,
|
|
199739
|
-
sourceInfos: result.sourceInfos,
|
|
199740
|
-
sources: result.sources,
|
|
199741
|
-
queries: result.queries,
|
|
199742
|
-
filterMap: new Map(result.filterMap.map(([k, v]) => [k, v])),
|
|
199743
|
-
givens: result.givens,
|
|
199744
|
-
compileDurationMs: result.compileDurationMs
|
|
199745
|
-
};
|
|
199746
|
-
}
|
|
199747
|
-
function serializeError(error) {
|
|
199748
|
-
if (error instanceof Error) {
|
|
199749
|
-
return {
|
|
199750
|
-
name: error.name,
|
|
199751
|
-
message: error.message,
|
|
199752
|
-
stack: error.stack
|
|
199753
|
-
};
|
|
199754
|
-
}
|
|
199755
|
-
return { name: "Error", message: String(error) };
|
|
199756
|
-
}
|
|
199757
|
-
function deserializeError(serialized) {
|
|
199758
|
-
const err = new Error(serialized.message);
|
|
199759
|
-
err.name = serialized.name;
|
|
199760
|
-
if (serialized.stack)
|
|
199761
|
-
err.stack = serialized.stack;
|
|
199762
|
-
if (serialized.malloyProblems) {
|
|
199763
|
-
err.problems = serialized.malloyProblems;
|
|
199764
|
-
}
|
|
199765
|
-
if (serialized.isCompilationError) {
|
|
199766
|
-
const wrapped = new ModelCompilationError(err);
|
|
199767
|
-
if (serialized.stack)
|
|
199768
|
-
wrapped.stack = serialized.stack;
|
|
199769
|
-
return wrapped;
|
|
199770
|
-
}
|
|
199771
|
-
return err;
|
|
199772
|
-
}
|
|
199773
|
-
function getCompilePool() {
|
|
199774
|
-
if (singleton === null) {
|
|
199775
|
-
const n = getCompileWorkerCount();
|
|
199776
|
-
singleton = new CompileWorkerPool(n);
|
|
199777
|
-
if (n > 0) {
|
|
199778
|
-
logger.info(`Malloy compile worker pool enabled (size=${n}). Set MALLOY_COMPILE_WORKERS=0 to disable.`);
|
|
199779
|
-
} else {
|
|
199780
|
-
logger.info("Malloy compile worker pool DISABLED (MALLOY_COMPILE_WORKERS=0). Compile runs on the main event loop.");
|
|
199781
|
-
}
|
|
199782
|
-
}
|
|
199783
|
-
return singleton;
|
|
199784
|
-
}
|
|
199785
|
-
async function __setCompilePoolForTests(pool) {
|
|
199786
|
-
if (singleton && singleton !== pool) {
|
|
199787
|
-
await singleton.shutdown();
|
|
199788
|
-
}
|
|
199789
|
-
singleton = pool;
|
|
199790
|
-
}
|
|
199791
|
-
var COMPILE_JOB_TIMEOUT_MS, defaultUrlReader, singleton = null;
|
|
199792
|
-
var init_compile_pool = __esm(() => {
|
|
199793
|
-
init_errors();
|
|
199794
|
-
init_logger();
|
|
199795
|
-
COMPILE_JOB_TIMEOUT_MS = Number.parseInt(process.env.MALLOY_COMPILE_JOB_TIMEOUT_MS ?? "120000", 10);
|
|
199796
|
-
defaultUrlReader = {
|
|
199797
|
-
readURL: async (url2) => {
|
|
199798
|
-
const { promises: fs3 } = await import("fs");
|
|
199799
|
-
const { fileURLToPath: fileURLToPath3 } = await import("url");
|
|
199800
|
-
const filePath = url2.protocol === "file:" ? fileURLToPath3(url2) : url2.toString();
|
|
199801
|
-
return fs3.readFile(filePath, "utf8");
|
|
199802
|
-
}
|
|
199803
|
-
};
|
|
199804
|
-
});
|
|
199805
|
-
|
|
199806
199159
|
// ../../node_modules/concat-map/index.js
|
|
199807
199160
|
var require_concat_map = __commonJS((exports, module) => {
|
|
199808
199161
|
module.exports = function(xs, fn) {
|
|
@@ -209769,7 +209122,7 @@ var require_util14 = __commonJS((exports) => {
|
|
|
209769
209122
|
return path12;
|
|
209770
209123
|
}
|
|
209771
209124
|
exports.normalize = normalize2;
|
|
209772
|
-
function
|
|
209125
|
+
function join8(aRoot, aPath) {
|
|
209773
209126
|
if (aRoot === "") {
|
|
209774
209127
|
aRoot = ".";
|
|
209775
209128
|
}
|
|
@@ -209801,7 +209154,7 @@ var require_util14 = __commonJS((exports) => {
|
|
|
209801
209154
|
}
|
|
209802
209155
|
return joined;
|
|
209803
209156
|
}
|
|
209804
|
-
exports.join =
|
|
209157
|
+
exports.join = join8;
|
|
209805
209158
|
exports.isAbsolute = function(aPath) {
|
|
209806
209159
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
209807
209160
|
};
|
|
@@ -209974,7 +209327,7 @@ var require_util14 = __commonJS((exports) => {
|
|
|
209974
209327
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
209975
209328
|
}
|
|
209976
209329
|
}
|
|
209977
|
-
sourceURL =
|
|
209330
|
+
sourceURL = join8(urlGenerate(parsed), sourceURL);
|
|
209978
209331
|
}
|
|
209979
209332
|
return normalize2(sourceURL);
|
|
209980
209333
|
}
|
|
@@ -212372,7 +211725,6 @@ var require_lib8 = __commonJS((exports, module) => {
|
|
|
212372
211725
|
});
|
|
212373
211726
|
|
|
212374
211727
|
// src/instrumentation.ts
|
|
212375
|
-
init_logger();
|
|
212376
211728
|
var import_api = __toESM(require_src(), 1);
|
|
212377
211729
|
var import_auto_instrumentations_node = __toESM(require_src59(), 1);
|
|
212378
211730
|
var import_exporter_logs_otlp_proto = __toESM(require_src66(), 1);
|
|
@@ -212384,6 +211736,94 @@ var import_sdk_logs = __toESM(require_src75(), 1);
|
|
|
212384
211736
|
var import_sdk_node = __toESM(require_src106(), 1);
|
|
212385
211737
|
var import_sdk_trace_base = __toESM(require_src82(), 1);
|
|
212386
211738
|
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
|
|
212387
211827
|
var prometheusExporter = null;
|
|
212388
211828
|
var sdk = null;
|
|
212389
211829
|
function getPrometheusMetricsHandler() {
|
|
@@ -212465,6 +211905,26 @@ var httpRequestDuration = meter.createHistogram("http_server_request_duration_ms
|
|
|
212465
211905
|
var httpRequestCount = meter.createCounter("http_server_requests_total", {
|
|
212466
211906
|
description: "Total number of HTTP requests"
|
|
212467
211907
|
});
|
|
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]);
|
|
212468
211928
|
var IGNORED_PATHS = new Set([
|
|
212469
211929
|
"/health",
|
|
212470
211930
|
"/health/liveness",
|
|
@@ -217506,7 +216966,7 @@ var import_express = __toESM(require_express(), 1);
|
|
|
217506
216966
|
var import_http_proxy_middleware = __toESM(require_dist4(), 1);
|
|
217507
216967
|
import * as http2 from "http";
|
|
217508
216968
|
import * as path12 from "path";
|
|
217509
|
-
import { fileURLToPath as
|
|
216969
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
217510
216970
|
|
|
217511
216971
|
// src/controller/compile.controller.ts
|
|
217512
216972
|
class CompileController {
|
|
@@ -217526,9 +216986,148 @@ class CompileController {
|
|
|
217526
216986
|
}
|
|
217527
216987
|
}
|
|
217528
216988
|
|
|
217529
|
-
// src/
|
|
217530
|
-
|
|
217531
|
-
|
|
216989
|
+
// src/errors.ts
|
|
216990
|
+
import { MalloyError } from "@malloydata/malloy";
|
|
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
|
+
}
|
|
217532
217131
|
|
|
217533
217132
|
// src/service/connection.ts
|
|
217534
217133
|
import"@malloydata/db-bigquery";
|
|
@@ -220813,12 +220412,10 @@ var {
|
|
|
220813
220412
|
} = axios_default;
|
|
220814
220413
|
|
|
220815
220414
|
// src/service/connection.ts
|
|
220816
|
-
init_logger();
|
|
220817
220415
|
import fs from "fs/promises";
|
|
220818
220416
|
import path2 from "path";
|
|
220819
220417
|
|
|
220820
220418
|
// src/pg_helpers.ts
|
|
220821
|
-
init_errors();
|
|
220822
220419
|
function pgConnectTimeoutSeconds() {
|
|
220823
220420
|
const raw = process.env.PG_CONNECT_TIMEOUT_SECONDS;
|
|
220824
220421
|
if (!raw)
|
|
@@ -222069,8 +221666,6 @@ async function testConnectionConfig(connectionConfig) {
|
|
|
222069
221666
|
}
|
|
222070
221667
|
|
|
222071
221668
|
// src/service/connection_service.ts
|
|
222072
|
-
init_errors();
|
|
222073
|
-
init_logger();
|
|
222074
221669
|
async function runEnvironmentConnectionUpdate(environment, fn) {
|
|
222075
221670
|
if (environment.runConnectionUpdateExclusive) {
|
|
222076
221671
|
return environment.runConnectionUpdateExclusive(fn);
|
|
@@ -222182,13 +221777,11 @@ class ConnectionService {
|
|
|
222182
221777
|
}
|
|
222183
221778
|
|
|
222184
221779
|
// src/service/db_utils.ts
|
|
222185
|
-
init_logger();
|
|
222186
221780
|
var import_bigquery = __toESM(require_src121(), 1);
|
|
222187
221781
|
import { ClientSecretCredential } from "@azure/identity";
|
|
222188
221782
|
import { ContainerClient } from "@azure/storage-blob";
|
|
222189
221783
|
|
|
222190
221784
|
// src/service/gcs_s3_utils.ts
|
|
222191
|
-
init_logger();
|
|
222192
221785
|
var import_client_s3 = __toESM(require_dist_cjs75(), 1);
|
|
222193
221786
|
function gcsConnectionToCredentials(gcsConnection) {
|
|
222194
221787
|
return {
|
|
@@ -223536,8 +223129,6 @@ class DatabaseController {
|
|
|
223536
223129
|
}
|
|
223537
223130
|
|
|
223538
223131
|
// src/controller/model.controller.ts
|
|
223539
|
-
init_errors();
|
|
223540
|
-
|
|
223541
223132
|
class ModelController {
|
|
223542
223133
|
environmentStore;
|
|
223543
223134
|
constructor(environmentStore) {
|
|
@@ -223599,9 +223190,6 @@ class ModelController {
|
|
|
223599
223190
|
}
|
|
223600
223191
|
|
|
223601
223192
|
// src/controller/package.controller.ts
|
|
223602
|
-
init_errors();
|
|
223603
|
-
init_logger();
|
|
223604
|
-
|
|
223605
223193
|
class PackageController {
|
|
223606
223194
|
environmentStore;
|
|
223607
223195
|
manifestService;
|
|
@@ -223714,8 +223302,6 @@ class PackageController {
|
|
|
223714
223302
|
}
|
|
223715
223303
|
|
|
223716
223304
|
// src/controller/query.controller.ts
|
|
223717
|
-
init_constants();
|
|
223718
|
-
init_errors();
|
|
223719
223305
|
var import_render_validator = __toESM(require_dist10(), 1);
|
|
223720
223306
|
function bigIntReplacer(_key, value) {
|
|
223721
223307
|
if (typeof value === "bigint") {
|
|
@@ -225319,7 +224905,6 @@ function watch(paths, options = {}) {
|
|
|
225319
224905
|
var esm_default = { watch, FSWatcher };
|
|
225320
224906
|
|
|
225321
224907
|
// src/controller/watch-mode.controller.ts
|
|
225322
|
-
init_logger();
|
|
225323
224908
|
import path11 from "path";
|
|
225324
224909
|
|
|
225325
224910
|
// src/service/environment_store.ts
|
|
@@ -225552,7 +225137,7 @@ var __defProp2 = Object.defineProperty;
|
|
|
225552
225137
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
225553
225138
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
225554
225139
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
225555
|
-
var
|
|
225140
|
+
var __esm = (fn, res) => function __init() {
|
|
225556
225141
|
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
225557
225142
|
};
|
|
225558
225143
|
var __commonJS2 = (cb, mod2) => function __require2() {
|
|
@@ -225583,13 +225168,13 @@ function toPaths(pathSpec) {
|
|
|
225583
225168
|
return cache.get(pathSpec) || [];
|
|
225584
225169
|
}
|
|
225585
225170
|
var cache;
|
|
225586
|
-
var init_pathspec =
|
|
225171
|
+
var init_pathspec = __esm({
|
|
225587
225172
|
"src/lib/args/pathspec.ts"() {
|
|
225588
225173
|
cache = /* @__PURE__ */ new WeakMap;
|
|
225589
225174
|
}
|
|
225590
225175
|
});
|
|
225591
225176
|
var GitError;
|
|
225592
|
-
var init_git_error =
|
|
225177
|
+
var init_git_error = __esm({
|
|
225593
225178
|
"src/lib/errors/git-error.ts"() {
|
|
225594
225179
|
GitError = class extends Error {
|
|
225595
225180
|
constructor(task, message) {
|
|
@@ -225601,7 +225186,7 @@ var init_git_error = __esm2({
|
|
|
225601
225186
|
}
|
|
225602
225187
|
});
|
|
225603
225188
|
var GitResponseError;
|
|
225604
|
-
var init_git_response_error =
|
|
225189
|
+
var init_git_response_error = __esm({
|
|
225605
225190
|
"src/lib/errors/git-response-error.ts"() {
|
|
225606
225191
|
init_git_error();
|
|
225607
225192
|
GitResponseError = class extends GitError {
|
|
@@ -225613,7 +225198,7 @@ var init_git_response_error = __esm2({
|
|
|
225613
225198
|
}
|
|
225614
225199
|
});
|
|
225615
225200
|
var TaskConfigurationError;
|
|
225616
|
-
var init_task_configuration_error =
|
|
225201
|
+
var init_task_configuration_error = __esm({
|
|
225617
225202
|
"src/lib/errors/task-configuration-error.ts"() {
|
|
225618
225203
|
init_git_error();
|
|
225619
225204
|
TaskConfigurationError = class extends GitError {
|
|
@@ -225736,7 +225321,7 @@ function orVoid(input) {
|
|
|
225736
225321
|
var NULL;
|
|
225737
225322
|
var NOOP;
|
|
225738
225323
|
var objectToString;
|
|
225739
|
-
var init_util =
|
|
225324
|
+
var init_util = __esm({
|
|
225740
225325
|
"src/lib/utils/util.ts"() {
|
|
225741
225326
|
NULL = "\x00";
|
|
225742
225327
|
NOOP = () => {};
|
|
@@ -225764,7 +225349,7 @@ var filterString;
|
|
|
225764
225349
|
var filterStringArray;
|
|
225765
225350
|
var filterStringOrStringArray;
|
|
225766
225351
|
var filterHasLength;
|
|
225767
|
-
var init_argument_filters =
|
|
225352
|
+
var init_argument_filters = __esm({
|
|
225768
225353
|
"src/lib/utils/argument-filters.ts"() {
|
|
225769
225354
|
init_util();
|
|
225770
225355
|
init_pathspec();
|
|
@@ -225789,7 +225374,7 @@ var init_argument_filters = __esm2({
|
|
|
225789
225374
|
}
|
|
225790
225375
|
});
|
|
225791
225376
|
var ExitCodes;
|
|
225792
|
-
var init_exit_codes =
|
|
225377
|
+
var init_exit_codes = __esm({
|
|
225793
225378
|
"src/lib/utils/exit-codes.ts"() {
|
|
225794
225379
|
ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
|
|
225795
225380
|
ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
|
|
@@ -225801,7 +225386,7 @@ var init_exit_codes = __esm2({
|
|
|
225801
225386
|
}
|
|
225802
225387
|
});
|
|
225803
225388
|
var GitOutputStreams;
|
|
225804
|
-
var init_git_output_streams =
|
|
225389
|
+
var init_git_output_streams = __esm({
|
|
225805
225390
|
"src/lib/utils/git-output-streams.ts"() {
|
|
225806
225391
|
GitOutputStreams = class _GitOutputStreams {
|
|
225807
225392
|
constructor(stdOut, stdErr) {
|
|
@@ -225816,7 +225401,7 @@ var init_git_output_streams = __esm2({
|
|
|
225816
225401
|
});
|
|
225817
225402
|
var LineParser;
|
|
225818
225403
|
var RemoteLineParser;
|
|
225819
|
-
var init_line_parser =
|
|
225404
|
+
var init_line_parser = __esm({
|
|
225820
225405
|
"src/lib/utils/line-parser.ts"() {
|
|
225821
225406
|
LineParser = class {
|
|
225822
225407
|
constructor(regExp, useMatches) {
|
|
@@ -225873,7 +225458,7 @@ function createInstanceConfig(...options) {
|
|
|
225873
225458
|
return config;
|
|
225874
225459
|
}
|
|
225875
225460
|
var defaultOptions2;
|
|
225876
|
-
var init_simple_git_options =
|
|
225461
|
+
var init_simple_git_options = __esm({
|
|
225877
225462
|
"src/lib/utils/simple-git-options.ts"() {
|
|
225878
225463
|
defaultOptions2 = {
|
|
225879
225464
|
binary: "git",
|
|
@@ -225930,7 +225515,7 @@ function trailingFunctionArgument(args, includeNoop = true) {
|
|
|
225930
225515
|
const callback = asFunction(last(args));
|
|
225931
225516
|
return includeNoop || isUserFunction(callback) ? callback : undefined;
|
|
225932
225517
|
}
|
|
225933
|
-
var init_task_options =
|
|
225518
|
+
var init_task_options = __esm({
|
|
225934
225519
|
"src/lib/utils/task-options.ts"() {
|
|
225935
225520
|
init_argument_filters();
|
|
225936
225521
|
init_util();
|
|
@@ -225954,7 +225539,7 @@ function parseStringResponse(result, parsers12, texts, trim2 = true) {
|
|
|
225954
225539
|
});
|
|
225955
225540
|
return result;
|
|
225956
225541
|
}
|
|
225957
|
-
var init_task_parser =
|
|
225542
|
+
var init_task_parser = __esm({
|
|
225958
225543
|
"src/lib/utils/task-parser.ts"() {
|
|
225959
225544
|
init_util();
|
|
225960
225545
|
}
|
|
@@ -226005,7 +225590,7 @@ __export2(utils_exports, {
|
|
|
226005
225590
|
trailingFunctionArgument: () => trailingFunctionArgument,
|
|
226006
225591
|
trailingOptionsArgument: () => trailingOptionsArgument
|
|
226007
225592
|
});
|
|
226008
|
-
var init_utils =
|
|
225593
|
+
var init_utils = __esm({
|
|
226009
225594
|
"src/lib/utils/index.ts"() {
|
|
226010
225595
|
init_argument_filters();
|
|
226011
225596
|
init_exit_codes();
|
|
@@ -226065,7 +225650,7 @@ function isNotRepoMessage(error) {
|
|
|
226065
225650
|
var CheckRepoActions;
|
|
226066
225651
|
var onError;
|
|
226067
225652
|
var parser;
|
|
226068
|
-
var init_check_is_repo =
|
|
225653
|
+
var init_check_is_repo = __esm({
|
|
226069
225654
|
"src/lib/tasks/check-is-repo.ts"() {
|
|
226070
225655
|
init_utils();
|
|
226071
225656
|
CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
|
|
@@ -226099,7 +225684,7 @@ var CleanResponse;
|
|
|
226099
225684
|
var removalRegexp;
|
|
226100
225685
|
var dryRunRemovalRegexp;
|
|
226101
225686
|
var isFolderRegexp;
|
|
226102
|
-
var init_CleanSummary =
|
|
225687
|
+
var init_CleanSummary = __esm({
|
|
226103
225688
|
"src/lib/responses/CleanSummary.ts"() {
|
|
226104
225689
|
init_utils();
|
|
226105
225690
|
CleanResponse = class {
|
|
@@ -226166,7 +225751,7 @@ function isEmptyTask(task) {
|
|
|
226166
225751
|
return task.format === "empty" || !task.commands.length;
|
|
226167
225752
|
}
|
|
226168
225753
|
var EMPTY_COMMANDS;
|
|
226169
|
-
var init_task =
|
|
225754
|
+
var init_task = __esm({
|
|
226170
225755
|
"src/lib/tasks/task.ts"() {
|
|
226171
225756
|
init_task_configuration_error();
|
|
226172
225757
|
EMPTY_COMMANDS = [];
|
|
@@ -226244,7 +225829,7 @@ var CONFIG_ERROR_MODE_REQUIRED;
|
|
|
226244
225829
|
var CONFIG_ERROR_UNKNOWN_OPTION;
|
|
226245
225830
|
var CleanOptions;
|
|
226246
225831
|
var CleanOptionValues;
|
|
226247
|
-
var init_clean =
|
|
225832
|
+
var init_clean = __esm({
|
|
226248
225833
|
"src/lib/tasks/clean.ts"() {
|
|
226249
225834
|
init_CleanSummary();
|
|
226250
225835
|
init_utils();
|
|
@@ -226317,7 +225902,7 @@ function* configParser(text, requestedKey = null) {
|
|
|
226317
225902
|
}
|
|
226318
225903
|
}
|
|
226319
225904
|
var ConfigList;
|
|
226320
|
-
var init_ConfigList =
|
|
225905
|
+
var init_ConfigList = __esm({
|
|
226321
225906
|
"src/lib/responses/ConfigList.ts"() {
|
|
226322
225907
|
init_utils();
|
|
226323
225908
|
ConfigList = class {
|
|
@@ -226415,7 +226000,7 @@ function config_default() {
|
|
|
226415
226000
|
};
|
|
226416
226001
|
}
|
|
226417
226002
|
var GitConfigScope;
|
|
226418
|
-
var init_config =
|
|
226003
|
+
var init_config = __esm({
|
|
226419
226004
|
"src/lib/tasks/config.ts"() {
|
|
226420
226005
|
init_ConfigList();
|
|
226421
226006
|
init_utils();
|
|
@@ -226433,7 +226018,7 @@ function isDiffNameStatus(input) {
|
|
|
226433
226018
|
}
|
|
226434
226019
|
var DiffNameStatus;
|
|
226435
226020
|
var diffNameStatus;
|
|
226436
|
-
var init_diff_name_status =
|
|
226021
|
+
var init_diff_name_status = __esm({
|
|
226437
226022
|
"src/lib/tasks/diff-name-status.ts"() {
|
|
226438
226023
|
DiffNameStatus = /* @__PURE__ */ ((DiffNameStatus2) => {
|
|
226439
226024
|
DiffNameStatus2["ADDED"] = "A";
|
|
@@ -226498,7 +226083,7 @@ var disallowedOptions;
|
|
|
226498
226083
|
var Query;
|
|
226499
226084
|
var _a;
|
|
226500
226085
|
var GrepQuery;
|
|
226501
|
-
var init_grep =
|
|
226086
|
+
var init_grep = __esm({
|
|
226502
226087
|
"src/lib/tasks/grep.ts"() {
|
|
226503
226088
|
init_utils();
|
|
226504
226089
|
init_task();
|
|
@@ -226554,7 +226139,7 @@ function isValidResetMode(mode) {
|
|
|
226554
226139
|
}
|
|
226555
226140
|
var ResetMode;
|
|
226556
226141
|
var ResetModes;
|
|
226557
|
-
var init_reset =
|
|
226142
|
+
var init_reset = __esm({
|
|
226558
226143
|
"src/lib/tasks/reset.ts"() {
|
|
226559
226144
|
init_task();
|
|
226560
226145
|
ResetMode = /* @__PURE__ */ ((ResetMode2) => {
|
|
@@ -226616,7 +226201,7 @@ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
|
|
|
226616
226201
|
});
|
|
226617
226202
|
}
|
|
226618
226203
|
}
|
|
226619
|
-
var init_git_logger =
|
|
226204
|
+
var init_git_logger = __esm({
|
|
226620
226205
|
"src/lib/git-logger.ts"() {
|
|
226621
226206
|
init_utils();
|
|
226622
226207
|
import_debug.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
|
|
@@ -226629,7 +226214,7 @@ var init_git_logger = __esm2({
|
|
|
226629
226214
|
}
|
|
226630
226215
|
});
|
|
226631
226216
|
var TasksPendingQueue;
|
|
226632
|
-
var init_tasks_pending_queue =
|
|
226217
|
+
var init_tasks_pending_queue = __esm({
|
|
226633
226218
|
"src/lib/runners/tasks-pending-queue.ts"() {
|
|
226634
226219
|
init_git_error();
|
|
226635
226220
|
init_git_logger();
|
|
@@ -226713,7 +226298,7 @@ function onDataReceived(target, name, logger2, output) {
|
|
|
226713
226298
|
};
|
|
226714
226299
|
}
|
|
226715
226300
|
var GitExecutorChain;
|
|
226716
|
-
var init_git_executor_chain =
|
|
226301
|
+
var init_git_executor_chain = __esm({
|
|
226717
226302
|
"src/lib/runners/git-executor-chain.ts"() {
|
|
226718
226303
|
init_git_error();
|
|
226719
226304
|
init_task();
|
|
@@ -226878,7 +226463,7 @@ __export2(git_executor_exports, {
|
|
|
226878
226463
|
GitExecutor: () => GitExecutor
|
|
226879
226464
|
});
|
|
226880
226465
|
var GitExecutor;
|
|
226881
|
-
var init_git_executor =
|
|
226466
|
+
var init_git_executor = __esm({
|
|
226882
226467
|
"src/lib/runners/git-executor.ts"() {
|
|
226883
226468
|
init_git_executor_chain();
|
|
226884
226469
|
GitExecutor = class {
|
|
@@ -226929,7 +226514,7 @@ function addDeprecationNoticeToError(err) {
|
|
|
226929
226514
|
return all3;
|
|
226930
226515
|
}
|
|
226931
226516
|
}
|
|
226932
|
-
var init_task_callback =
|
|
226517
|
+
var init_task_callback = __esm({
|
|
226933
226518
|
"src/lib/task-callback.ts"() {
|
|
226934
226519
|
init_git_response_error();
|
|
226935
226520
|
init_utils();
|
|
@@ -226943,7 +226528,7 @@ function changeWorkingDirectoryTask(directory, root) {
|
|
|
226943
226528
|
return (root || instance).cwd = directory;
|
|
226944
226529
|
});
|
|
226945
226530
|
}
|
|
226946
|
-
var init_change_working_directory =
|
|
226531
|
+
var init_change_working_directory = __esm({
|
|
226947
226532
|
"src/lib/tasks/change-working-directory.ts"() {
|
|
226948
226533
|
init_utils();
|
|
226949
226534
|
init_task();
|
|
@@ -226969,7 +226554,7 @@ function checkout_default() {
|
|
|
226969
226554
|
}
|
|
226970
226555
|
};
|
|
226971
226556
|
}
|
|
226972
|
-
var init_checkout =
|
|
226557
|
+
var init_checkout = __esm({
|
|
226973
226558
|
"src/lib/tasks/checkout.ts"() {
|
|
226974
226559
|
init_utils();
|
|
226975
226560
|
init_task();
|
|
@@ -227001,7 +226586,7 @@ function count_objects_default() {
|
|
|
227001
226586
|
};
|
|
227002
226587
|
}
|
|
227003
226588
|
var parser2;
|
|
227004
|
-
var init_count_objects =
|
|
226589
|
+
var init_count_objects = __esm({
|
|
227005
226590
|
"src/lib/tasks/count-objects.ts"() {
|
|
227006
226591
|
init_utils();
|
|
227007
226592
|
parser2 = new LineParser(/([a-z-]+): (\d+)$/, (result, [key, value]) => {
|
|
@@ -227027,7 +226612,7 @@ function parseCommitResult(stdOut) {
|
|
|
227027
226612
|
return parseStringResponse(result, parsers, stdOut);
|
|
227028
226613
|
}
|
|
227029
226614
|
var parsers;
|
|
227030
|
-
var init_parse_commit =
|
|
226615
|
+
var init_parse_commit = __esm({
|
|
227031
226616
|
"src/lib/parsers/parse-commit.ts"() {
|
|
227032
226617
|
init_utils();
|
|
227033
226618
|
parsers = [
|
|
@@ -227091,7 +226676,7 @@ function commit_default() {
|
|
|
227091
226676
|
return !filterStringOrStringArray(message) && configurationErrorTask(`git.commit: requires the commit message to be supplied as a string/string[]`);
|
|
227092
226677
|
}
|
|
227093
226678
|
}
|
|
227094
|
-
var init_commit =
|
|
226679
|
+
var init_commit = __esm({
|
|
227095
226680
|
"src/lib/tasks/commit.ts"() {
|
|
227096
226681
|
init_parse_commit();
|
|
227097
226682
|
init_utils();
|
|
@@ -227105,7 +226690,7 @@ function first_commit_default() {
|
|
|
227105
226690
|
}
|
|
227106
226691
|
};
|
|
227107
226692
|
}
|
|
227108
|
-
var init_first_commit =
|
|
226693
|
+
var init_first_commit = __esm({
|
|
227109
226694
|
"src/lib/tasks/first-commit.ts"() {
|
|
227110
226695
|
init_utils();
|
|
227111
226696
|
init_task();
|
|
@@ -227118,7 +226703,7 @@ function hashObjectTask(filePath, write) {
|
|
|
227118
226703
|
}
|
|
227119
226704
|
return straightThroughStringTask(commands, true);
|
|
227120
226705
|
}
|
|
227121
|
-
var init_hash_object =
|
|
226706
|
+
var init_hash_object = __esm({
|
|
227122
226707
|
"src/lib/tasks/hash-object.ts"() {
|
|
227123
226708
|
init_task();
|
|
227124
226709
|
}
|
|
@@ -227146,7 +226731,7 @@ function parseInit(bare, path3, text) {
|
|
|
227146
226731
|
var InitSummary;
|
|
227147
226732
|
var initResponseRegex;
|
|
227148
226733
|
var reInitResponseRegex;
|
|
227149
|
-
var init_InitSummary =
|
|
226734
|
+
var init_InitSummary = __esm({
|
|
227150
226735
|
"src/lib/responses/InitSummary.ts"() {
|
|
227151
226736
|
InitSummary = class {
|
|
227152
226737
|
constructor(bare, path3, existing, gitDir) {
|
|
@@ -227177,7 +226762,7 @@ function initTask(bare = false, path3, customArgs) {
|
|
|
227177
226762
|
};
|
|
227178
226763
|
}
|
|
227179
226764
|
var bareCommand;
|
|
227180
|
-
var init_init =
|
|
226765
|
+
var init_init = __esm({
|
|
227181
226766
|
"src/lib/tasks/init.ts"() {
|
|
227182
226767
|
init_InitSummary();
|
|
227183
226768
|
bareCommand = "--bare";
|
|
@@ -227196,13 +226781,13 @@ function isLogFormat(customArg) {
|
|
|
227196
226781
|
return logFormatRegex.test(customArg);
|
|
227197
226782
|
}
|
|
227198
226783
|
var logFormatRegex;
|
|
227199
|
-
var init_log_format =
|
|
226784
|
+
var init_log_format = __esm({
|
|
227200
226785
|
"src/lib/args/log-format.ts"() {
|
|
227201
226786
|
logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
|
|
227202
226787
|
}
|
|
227203
226788
|
});
|
|
227204
226789
|
var DiffSummary;
|
|
227205
|
-
var init_DiffSummary =
|
|
226790
|
+
var init_DiffSummary = __esm({
|
|
227206
226791
|
"src/lib/responses/DiffSummary.ts"() {
|
|
227207
226792
|
DiffSummary = class {
|
|
227208
226793
|
constructor() {
|
|
@@ -227223,7 +226808,7 @@ var numStatParser;
|
|
|
227223
226808
|
var nameOnlyParser;
|
|
227224
226809
|
var nameStatusParser;
|
|
227225
226810
|
var diffSummaryParsers;
|
|
227226
|
-
var init_parse_diff_summary =
|
|
226811
|
+
var init_parse_diff_summary = __esm({
|
|
227227
226812
|
"src/lib/parsers/parse-diff-summary.ts"() {
|
|
227228
226813
|
init_log_format();
|
|
227229
226814
|
init_DiffSummary();
|
|
@@ -227344,7 +226929,7 @@ var START_BOUNDARY;
|
|
|
227344
226929
|
var COMMIT_BOUNDARY;
|
|
227345
226930
|
var SPLITTER;
|
|
227346
226931
|
var defaultFieldNames;
|
|
227347
|
-
var init_parse_list_log_summary =
|
|
226932
|
+
var init_parse_list_log_summary = __esm({
|
|
227348
226933
|
"src/lib/parsers/parse-list-log-summary.ts"() {
|
|
227349
226934
|
init_utils();
|
|
227350
226935
|
init_parse_diff_summary();
|
|
@@ -227383,7 +226968,7 @@ function validateLogFormatConfig(customArgs) {
|
|
|
227383
226968
|
return configurationErrorTask(`Summary flag ${flags} parsing is not compatible with null termination option '-z'`);
|
|
227384
226969
|
}
|
|
227385
226970
|
}
|
|
227386
|
-
var init_diff =
|
|
226971
|
+
var init_diff = __esm({
|
|
227387
226972
|
"src/lib/tasks/diff.ts"() {
|
|
227388
226973
|
init_log_format();
|
|
227389
226974
|
init_parse_diff_summary();
|
|
@@ -227467,7 +227052,7 @@ function log_default() {
|
|
|
227467
227052
|
}
|
|
227468
227053
|
}
|
|
227469
227054
|
var excludeOptions;
|
|
227470
|
-
var init_log =
|
|
227055
|
+
var init_log = __esm({
|
|
227471
227056
|
"src/lib/tasks/log.ts"() {
|
|
227472
227057
|
init_log_format();
|
|
227473
227058
|
init_pathspec();
|
|
@@ -227495,7 +227080,7 @@ var init_log = __esm2({
|
|
|
227495
227080
|
});
|
|
227496
227081
|
var MergeSummaryConflict;
|
|
227497
227082
|
var MergeSummaryDetail;
|
|
227498
|
-
var init_MergeSummary =
|
|
227083
|
+
var init_MergeSummary = __esm({
|
|
227499
227084
|
"src/lib/responses/MergeSummary.ts"() {
|
|
227500
227085
|
MergeSummaryConflict = class {
|
|
227501
227086
|
constructor(reason, file = null, meta) {
|
|
@@ -227530,7 +227115,7 @@ var init_MergeSummary = __esm2({
|
|
|
227530
227115
|
});
|
|
227531
227116
|
var PullSummary;
|
|
227532
227117
|
var PullFailedSummary;
|
|
227533
|
-
var init_PullSummary =
|
|
227118
|
+
var init_PullSummary = __esm({
|
|
227534
227119
|
"src/lib/responses/PullSummary.ts"() {
|
|
227535
227120
|
PullSummary = class {
|
|
227536
227121
|
constructor() {
|
|
@@ -227587,7 +227172,7 @@ function asObjectCount(source) {
|
|
|
227587
227172
|
};
|
|
227588
227173
|
}
|
|
227589
227174
|
var remoteMessagesObjectParsers;
|
|
227590
|
-
var init_parse_remote_objects =
|
|
227175
|
+
var init_parse_remote_objects = __esm({
|
|
227591
227176
|
"src/lib/parsers/parse-remote-objects.ts"() {
|
|
227592
227177
|
init_utils();
|
|
227593
227178
|
remoteMessagesObjectParsers = [
|
|
@@ -227615,7 +227200,7 @@ function parseRemoteMessages(_stdOut, stdErr) {
|
|
|
227615
227200
|
}
|
|
227616
227201
|
var parsers2;
|
|
227617
227202
|
var RemoteMessageSummary;
|
|
227618
|
-
var init_parse_remote_messages =
|
|
227203
|
+
var init_parse_remote_messages = __esm({
|
|
227619
227204
|
"src/lib/parsers/parse-remote-messages.ts"() {
|
|
227620
227205
|
init_utils();
|
|
227621
227206
|
init_parse_remote_objects();
|
|
@@ -227654,7 +227239,7 @@ var parsers3;
|
|
|
227654
227239
|
var errorParsers;
|
|
227655
227240
|
var parsePullDetail;
|
|
227656
227241
|
var parsePullResult;
|
|
227657
|
-
var init_parse_pull =
|
|
227242
|
+
var init_parse_pull = __esm({
|
|
227658
227243
|
"src/lib/parsers/parse-pull.ts"() {
|
|
227659
227244
|
init_PullSummary();
|
|
227660
227245
|
init_utils();
|
|
@@ -227707,7 +227292,7 @@ var init_parse_pull = __esm2({
|
|
|
227707
227292
|
var parsers4;
|
|
227708
227293
|
var parseMergeResult;
|
|
227709
227294
|
var parseMergeDetail;
|
|
227710
|
-
var init_parse_merge =
|
|
227295
|
+
var init_parse_merge = __esm({
|
|
227711
227296
|
"src/lib/parsers/parse-merge.ts"() {
|
|
227712
227297
|
init_MergeSummary();
|
|
227713
227298
|
init_utils();
|
|
@@ -227753,7 +227338,7 @@ function mergeTask(customArgs) {
|
|
|
227753
227338
|
}
|
|
227754
227339
|
};
|
|
227755
227340
|
}
|
|
227756
|
-
var init_merge =
|
|
227341
|
+
var init_merge = __esm({
|
|
227757
227342
|
"src/lib/tasks/merge.ts"() {
|
|
227758
227343
|
init_git_response_error();
|
|
227759
227344
|
init_parse_merge();
|
|
@@ -227777,7 +227362,7 @@ function pushResultPushedItem(local, remote, status) {
|
|
|
227777
227362
|
var parsers5;
|
|
227778
227363
|
var parsePushResult;
|
|
227779
227364
|
var parsePushDetail;
|
|
227780
|
-
var init_parse_push =
|
|
227365
|
+
var init_parse_push = __esm({
|
|
227781
227366
|
"src/lib/parsers/parse-push.ts"() {
|
|
227782
227367
|
init_utils();
|
|
227783
227368
|
init_parse_remote_messages();
|
|
@@ -227854,7 +227439,7 @@ function pushTask(ref = {}, customArgs) {
|
|
|
227854
227439
|
parser: parsePushResult
|
|
227855
227440
|
};
|
|
227856
227441
|
}
|
|
227857
|
-
var init_push =
|
|
227442
|
+
var init_push = __esm({
|
|
227858
227443
|
"src/lib/tasks/push.ts"() {
|
|
227859
227444
|
init_parse_push();
|
|
227860
227445
|
init_utils();
|
|
@@ -227875,7 +227460,7 @@ function show_default() {
|
|
|
227875
227460
|
}
|
|
227876
227461
|
};
|
|
227877
227462
|
}
|
|
227878
|
-
var init_show =
|
|
227463
|
+
var init_show = __esm({
|
|
227879
227464
|
"src/lib/tasks/show.ts"() {
|
|
227880
227465
|
init_utils();
|
|
227881
227466
|
init_task();
|
|
@@ -227883,7 +227468,7 @@ var init_show = __esm2({
|
|
|
227883
227468
|
});
|
|
227884
227469
|
var fromPathRegex;
|
|
227885
227470
|
var FileStatusSummary;
|
|
227886
|
-
var init_FileStatusSummary =
|
|
227471
|
+
var init_FileStatusSummary = __esm({
|
|
227887
227472
|
"src/lib/responses/FileStatusSummary.ts"() {
|
|
227888
227473
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
227889
227474
|
FileStatusSummary = class {
|
|
@@ -227937,7 +227522,7 @@ function splitLine(result, lineStr) {
|
|
|
227937
227522
|
var StatusSummary;
|
|
227938
227523
|
var parsers6;
|
|
227939
227524
|
var parseStatusSummary;
|
|
227940
|
-
var init_StatusSummary =
|
|
227525
|
+
var init_StatusSummary = __esm({
|
|
227941
227526
|
"src/lib/responses/StatusSummary.ts"() {
|
|
227942
227527
|
init_utils();
|
|
227943
227528
|
init_FileStatusSummary();
|
|
@@ -228044,7 +227629,7 @@ function statusTask(customArgs) {
|
|
|
228044
227629
|
};
|
|
228045
227630
|
}
|
|
228046
227631
|
var ignoredOptions;
|
|
228047
|
-
var init_status =
|
|
227632
|
+
var init_status = __esm({
|
|
228048
227633
|
"src/lib/tasks/status.ts"() {
|
|
228049
227634
|
init_StatusSummary();
|
|
228050
227635
|
ignoredOptions = ["--null", "-z"];
|
|
@@ -228093,7 +227678,7 @@ function versionParser(stdOut) {
|
|
|
228093
227678
|
}
|
|
228094
227679
|
var NOT_INSTALLED;
|
|
228095
227680
|
var parsers7;
|
|
228096
|
-
var init_version =
|
|
227681
|
+
var init_version = __esm({
|
|
228097
227682
|
"src/lib/tasks/version.ts"() {
|
|
228098
227683
|
init_utils();
|
|
228099
227684
|
NOT_INSTALLED = "installed=false";
|
|
@@ -228112,7 +227697,7 @@ __export2(simple_git_api_exports, {
|
|
|
228112
227697
|
SimpleGitApi: () => SimpleGitApi
|
|
228113
227698
|
});
|
|
228114
227699
|
var SimpleGitApi;
|
|
228115
|
-
var init_simple_git_api =
|
|
227700
|
+
var init_simple_git_api = __esm({
|
|
228116
227701
|
"src/lib/simple-git-api.ts"() {
|
|
228117
227702
|
init_task_callback();
|
|
228118
227703
|
init_change_working_directory();
|
|
@@ -228203,7 +227788,7 @@ __export2(scheduler_exports, {
|
|
|
228203
227788
|
});
|
|
228204
227789
|
var createScheduledTask;
|
|
228205
227790
|
var Scheduler;
|
|
228206
|
-
var init_scheduler =
|
|
227791
|
+
var init_scheduler = __esm({
|
|
228207
227792
|
"src/lib/runners/scheduler.ts"() {
|
|
228208
227793
|
init_utils();
|
|
228209
227794
|
init_git_logger();
|
|
@@ -228256,7 +227841,7 @@ __export2(apply_patch_exports, {
|
|
|
228256
227841
|
function applyPatchTask(patches, customArgs) {
|
|
228257
227842
|
return straightThroughStringTask(["apply", ...customArgs, ...patches]);
|
|
228258
227843
|
}
|
|
228259
|
-
var init_apply_patch =
|
|
227844
|
+
var init_apply_patch = __esm({
|
|
228260
227845
|
"src/lib/tasks/apply-patch.ts"() {
|
|
228261
227846
|
init_task();
|
|
228262
227847
|
}
|
|
@@ -228276,7 +227861,7 @@ function branchDeletionFailure(branch) {
|
|
|
228276
227861
|
};
|
|
228277
227862
|
}
|
|
228278
227863
|
var BranchDeletionBatch;
|
|
228279
|
-
var init_BranchDeleteSummary =
|
|
227864
|
+
var init_BranchDeleteSummary = __esm({
|
|
228280
227865
|
"src/lib/responses/BranchDeleteSummary.ts"() {
|
|
228281
227866
|
BranchDeletionBatch = class {
|
|
228282
227867
|
constructor() {
|
|
@@ -228297,7 +227882,7 @@ var deleteSuccessRegex;
|
|
|
228297
227882
|
var deleteErrorRegex;
|
|
228298
227883
|
var parsers8;
|
|
228299
227884
|
var parseBranchDeletions;
|
|
228300
|
-
var init_parse_branch_delete =
|
|
227885
|
+
var init_parse_branch_delete = __esm({
|
|
228301
227886
|
"src/lib/parsers/parse-branch-delete.ts"() {
|
|
228302
227887
|
init_BranchDeleteSummary();
|
|
228303
227888
|
init_utils();
|
|
@@ -228322,7 +227907,7 @@ var init_parse_branch_delete = __esm2({
|
|
|
228322
227907
|
}
|
|
228323
227908
|
});
|
|
228324
227909
|
var BranchSummaryResult;
|
|
228325
|
-
var init_BranchSummary =
|
|
227910
|
+
var init_BranchSummary = __esm({
|
|
228326
227911
|
"src/lib/responses/BranchSummary.ts"() {
|
|
228327
227912
|
BranchSummaryResult = class {
|
|
228328
227913
|
constructor() {
|
|
@@ -228355,7 +227940,7 @@ function parseBranchSummary(stdOut) {
|
|
|
228355
227940
|
return parseStringResponse(new BranchSummaryResult, parsers9, stdOut);
|
|
228356
227941
|
}
|
|
228357
227942
|
var parsers9;
|
|
228358
|
-
var init_parse_branch =
|
|
227943
|
+
var init_parse_branch = __esm({
|
|
228359
227944
|
"src/lib/parsers/parse-branch.ts"() {
|
|
228360
227945
|
init_BranchSummary();
|
|
228361
227946
|
init_utils();
|
|
@@ -228440,7 +228025,7 @@ function deleteBranchTask(branch, forceDelete = false) {
|
|
|
228440
228025
|
};
|
|
228441
228026
|
return task;
|
|
228442
228027
|
}
|
|
228443
|
-
var init_branch =
|
|
228028
|
+
var init_branch = __esm({
|
|
228444
228029
|
"src/lib/tasks/branch.ts"() {
|
|
228445
228030
|
init_git_response_error();
|
|
228446
228031
|
init_parse_branch_delete();
|
|
@@ -228449,7 +228034,7 @@ var init_branch = __esm2({
|
|
|
228449
228034
|
}
|
|
228450
228035
|
});
|
|
228451
228036
|
var parseCheckIgnore;
|
|
228452
|
-
var init_CheckIgnore =
|
|
228037
|
+
var init_CheckIgnore = __esm({
|
|
228453
228038
|
"src/lib/responses/CheckIgnore.ts"() {
|
|
228454
228039
|
parseCheckIgnore = (text) => {
|
|
228455
228040
|
return text.split(/\n/g).map((line) => line.trim()).filter((file) => !!file);
|
|
@@ -228467,7 +228052,7 @@ function checkIgnoreTask(paths) {
|
|
|
228467
228052
|
parser: parseCheckIgnore
|
|
228468
228053
|
};
|
|
228469
228054
|
}
|
|
228470
|
-
var init_check_ignore =
|
|
228055
|
+
var init_check_ignore = __esm({
|
|
228471
228056
|
"src/lib/tasks/check-ignore.ts"() {
|
|
228472
228057
|
init_CheckIgnore();
|
|
228473
228058
|
}
|
|
@@ -228494,7 +228079,7 @@ function cloneMirrorTask(repo, directory, customArgs) {
|
|
|
228494
228079
|
append2(customArgs, "--mirror");
|
|
228495
228080
|
return cloneTask(repo, directory, customArgs);
|
|
228496
228081
|
}
|
|
228497
|
-
var init_clone =
|
|
228082
|
+
var init_clone = __esm({
|
|
228498
228083
|
"src/lib/tasks/clone.ts"() {
|
|
228499
228084
|
init_task();
|
|
228500
228085
|
init_utils();
|
|
@@ -228512,7 +228097,7 @@ function parseFetchResult(stdOut, stdErr) {
|
|
|
228512
228097
|
return parseStringResponse(result, parsers10, [stdOut, stdErr]);
|
|
228513
228098
|
}
|
|
228514
228099
|
var parsers10;
|
|
228515
|
-
var init_parse_fetch =
|
|
228100
|
+
var init_parse_fetch = __esm({
|
|
228516
228101
|
"src/lib/parsers/parse-fetch.ts"() {
|
|
228517
228102
|
init_utils();
|
|
228518
228103
|
parsers10 = [
|
|
@@ -228569,7 +228154,7 @@ function fetchTask(remote, branch, customArgs) {
|
|
|
228569
228154
|
parser: parseFetchResult
|
|
228570
228155
|
};
|
|
228571
228156
|
}
|
|
228572
|
-
var init_fetch =
|
|
228157
|
+
var init_fetch = __esm({
|
|
228573
228158
|
"src/lib/tasks/fetch.ts"() {
|
|
228574
228159
|
init_parse_fetch();
|
|
228575
228160
|
init_task();
|
|
@@ -228579,7 +228164,7 @@ function parseMoveResult(stdOut) {
|
|
|
228579
228164
|
return parseStringResponse({ moves: [] }, parsers11, stdOut);
|
|
228580
228165
|
}
|
|
228581
228166
|
var parsers11;
|
|
228582
|
-
var init_parse_move =
|
|
228167
|
+
var init_parse_move = __esm({
|
|
228583
228168
|
"src/lib/parsers/parse-move.ts"() {
|
|
228584
228169
|
init_utils();
|
|
228585
228170
|
parsers11 = [
|
|
@@ -228600,7 +228185,7 @@ function moveTask(from, to) {
|
|
|
228600
228185
|
parser: parseMoveResult
|
|
228601
228186
|
};
|
|
228602
228187
|
}
|
|
228603
|
-
var init_move =
|
|
228188
|
+
var init_move = __esm({
|
|
228604
228189
|
"src/lib/tasks/move.ts"() {
|
|
228605
228190
|
init_parse_move();
|
|
228606
228191
|
init_utils();
|
|
@@ -228630,7 +228215,7 @@ function pullTask(remote, branch, customArgs) {
|
|
|
228630
228215
|
}
|
|
228631
228216
|
};
|
|
228632
228217
|
}
|
|
228633
|
-
var init_pull =
|
|
228218
|
+
var init_pull = __esm({
|
|
228634
228219
|
"src/lib/tasks/pull.ts"() {
|
|
228635
228220
|
init_git_response_error();
|
|
228636
228221
|
init_parse_pull();
|
|
@@ -228660,7 +228245,7 @@ function parseGetRemotesVerbose(text) {
|
|
|
228660
228245
|
function forEach2(text, handler) {
|
|
228661
228246
|
forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
|
|
228662
228247
|
}
|
|
228663
|
-
var init_GetRemoteSummary =
|
|
228248
|
+
var init_GetRemoteSummary = __esm({
|
|
228664
228249
|
"src/lib/responses/GetRemoteSummary.ts"() {
|
|
228665
228250
|
init_utils();
|
|
228666
228251
|
}
|
|
@@ -228704,7 +228289,7 @@ function remoteTask(customArgs) {
|
|
|
228704
228289
|
function removeRemoteTask(remoteName) {
|
|
228705
228290
|
return straightThroughStringTask(["remote", "remove", remoteName]);
|
|
228706
228291
|
}
|
|
228707
|
-
var init_remote =
|
|
228292
|
+
var init_remote = __esm({
|
|
228708
228293
|
"src/lib/tasks/remote.ts"() {
|
|
228709
228294
|
init_GetRemoteSummary();
|
|
228710
228295
|
init_task();
|
|
@@ -228724,7 +228309,7 @@ function stashListTask(opt = {}, customArgs) {
|
|
|
228724
228309
|
parser: parser4
|
|
228725
228310
|
};
|
|
228726
228311
|
}
|
|
228727
|
-
var init_stash_list =
|
|
228312
|
+
var init_stash_list = __esm({
|
|
228728
228313
|
"src/lib/tasks/stash-list.ts"() {
|
|
228729
228314
|
init_log_format();
|
|
228730
228315
|
init_parse_list_log_summary();
|
|
@@ -228755,7 +228340,7 @@ function subModuleTask(customArgs) {
|
|
|
228755
228340
|
function updateSubModuleTask(customArgs) {
|
|
228756
228341
|
return subModuleTask(["update", ...customArgs]);
|
|
228757
228342
|
}
|
|
228758
|
-
var init_sub_module =
|
|
228343
|
+
var init_sub_module = __esm({
|
|
228759
228344
|
"src/lib/tasks/sub-module.ts"() {
|
|
228760
228345
|
init_task();
|
|
228761
228346
|
}
|
|
@@ -228782,7 +228367,7 @@ function toNumber(input) {
|
|
|
228782
228367
|
}
|
|
228783
228368
|
var TagList;
|
|
228784
228369
|
var parseTagList;
|
|
228785
|
-
var init_TagList =
|
|
228370
|
+
var init_TagList = __esm({
|
|
228786
228371
|
"src/lib/responses/TagList.ts"() {
|
|
228787
228372
|
TagList = class {
|
|
228788
228373
|
constructor(all3, latest) {
|
|
@@ -228848,7 +228433,7 @@ function addAnnotatedTagTask(name, tagMessage) {
|
|
|
228848
228433
|
}
|
|
228849
228434
|
};
|
|
228850
228435
|
}
|
|
228851
|
-
var init_tag =
|
|
228436
|
+
var init_tag = __esm({
|
|
228852
228437
|
"src/lib/tasks/tag.ts"() {
|
|
228853
228438
|
init_TagList();
|
|
228854
228439
|
}
|
|
@@ -229524,8 +229109,6 @@ var esm_default2 = gitInstanceFactory;
|
|
|
229524
229109
|
import { Writable } from "stream";
|
|
229525
229110
|
|
|
229526
229111
|
// src/config.ts
|
|
229527
|
-
init_constants();
|
|
229528
|
-
init_logger();
|
|
229529
229112
|
import fs2 from "fs";
|
|
229530
229113
|
import path3 from "path";
|
|
229531
229114
|
import { fileURLToPath } from "url";
|
|
@@ -229783,12 +229366,7 @@ var getProcessedPublisherConfig = (serverRoot) => {
|
|
|
229783
229366
|
};
|
|
229784
229367
|
};
|
|
229785
229368
|
|
|
229786
|
-
// src/service/environment_store.ts
|
|
229787
|
-
init_constants();
|
|
229788
|
-
init_errors();
|
|
229789
|
-
|
|
229790
229369
|
// src/health.ts
|
|
229791
|
-
init_logger();
|
|
229792
229370
|
var operationalState = "initializing";
|
|
229793
229371
|
var ready = false;
|
|
229794
229372
|
var preGracefulShutdownCompleted = false;
|
|
@@ -229844,11 +229422,6 @@ async function performGracefulShutdownAfterDrain(server, mcpServer, shutdownGrac
|
|
|
229844
229422
|
await shutdownSDK();
|
|
229845
229423
|
logger.info("OpenTelemetry SDK shut down");
|
|
229846
229424
|
} catch (_error) {}
|
|
229847
|
-
try {
|
|
229848
|
-
const { getCompilePool: getCompilePool2 } = await Promise.resolve().then(() => (init_compile_pool(), exports_compile_pool));
|
|
229849
|
-
await getCompilePool2().shutdown();
|
|
229850
|
-
logger.info("Malloy compile worker pool shut down");
|
|
229851
|
-
} catch (_error) {}
|
|
229852
229425
|
if (shutdownGracefulCloseTimeoutSeconds > 0) {
|
|
229853
229426
|
logger.info(`Waiting ${shutdownGracefulCloseTimeoutSeconds} seconds after server close before exit...`);
|
|
229854
229427
|
await new Promise((resolve3) => setTimeout(resolve3, shutdownGracefulCloseTimeoutSeconds * 1000));
|
|
@@ -229890,12 +229463,7 @@ function registerHealthEndpoints(app) {
|
|
|
229890
229463
|
});
|
|
229891
229464
|
}
|
|
229892
229465
|
|
|
229893
|
-
// src/service/environment_store.ts
|
|
229894
|
-
init_logger();
|
|
229895
|
-
|
|
229896
229466
|
// src/storage/StorageManager.ts
|
|
229897
|
-
init_errors();
|
|
229898
|
-
init_logger();
|
|
229899
229467
|
import * as crypto3 from "crypto";
|
|
229900
229468
|
|
|
229901
229469
|
// src/storage/duckdb/DuckDBConnection.ts
|
|
@@ -230702,7 +230270,6 @@ class DuckDBRepository {
|
|
|
230702
230270
|
}
|
|
230703
230271
|
|
|
230704
230272
|
// src/storage/duckdb/schema.ts
|
|
230705
|
-
init_logger();
|
|
230706
230273
|
async function initializeSchema(db, force = false) {
|
|
230707
230274
|
const initialized = await db.isInitialized();
|
|
230708
230275
|
if (initialized && !force) {
|
|
@@ -230831,8 +230398,6 @@ async function dropAllTables(db) {
|
|
|
230831
230398
|
}
|
|
230832
230399
|
|
|
230833
230400
|
// src/storage/ducklake/DuckLakeManifestStore.ts
|
|
230834
|
-
init_logger();
|
|
230835
|
-
|
|
230836
230401
|
class DuckLakeManifestStore {
|
|
230837
230402
|
db;
|
|
230838
230403
|
table;
|
|
@@ -231060,15 +230625,11 @@ class StorageManager {
|
|
|
231060
230625
|
|
|
231061
230626
|
// src/service/environment.ts
|
|
231062
230627
|
import { MalloyError as MalloyError3, Runtime as Runtime2 } from "@malloydata/malloy";
|
|
231063
|
-
init_constants();
|
|
231064
|
-
init_errors();
|
|
231065
|
-
init_logger();
|
|
231066
230628
|
import crypto4 from "crypto";
|
|
231067
230629
|
import * as fs6 from "fs";
|
|
231068
230630
|
import * as path9 from "path";
|
|
231069
230631
|
|
|
231070
230632
|
// src/path_safety.ts
|
|
231071
|
-
init_errors();
|
|
231072
230633
|
import * as path5 from "path";
|
|
231073
230634
|
var SAFE_NAME_RE = /^(?!\.\.?$)(?!\.)[A-Za-z0-9._-]{1,255}$/;
|
|
231074
230635
|
var MAX_MODEL_PATH_LEN = 1024;
|
|
@@ -231123,12 +230684,12 @@ function safeJoinUnderRoot(root, ...segments) {
|
|
|
231123
230684
|
// src/utils.ts
|
|
231124
230685
|
import * as fs3 from "fs";
|
|
231125
230686
|
import * as path6 from "path";
|
|
231126
|
-
import { fileURLToPath as
|
|
230687
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
231127
230688
|
var URL_READER = {
|
|
231128
230689
|
readURL: (url2) => {
|
|
231129
230690
|
let path7 = url2.toString();
|
|
231130
230691
|
if (url2.protocol == "file:") {
|
|
231131
|
-
path7 =
|
|
230692
|
+
path7 = fileURLToPath2(url2);
|
|
231132
230693
|
}
|
|
231133
230694
|
return fs3.promises.readFile(path7, "utf8");
|
|
231134
230695
|
}
|
|
@@ -231138,26 +230699,17 @@ function ignoreDotfiles(file) {
|
|
|
231138
230699
|
}
|
|
231139
230700
|
|
|
231140
230701
|
// src/service/package.ts
|
|
231141
|
-
init_constants();
|
|
231142
|
-
init_errors();
|
|
231143
|
-
init_logger();
|
|
231144
230702
|
var import_api3 = __toESM(require_src(), 1);
|
|
231145
230703
|
var import_recursive_readdir = __toESM(require_recursive_readdir(), 1);
|
|
231146
230704
|
import * as fs5 from "fs/promises";
|
|
231147
230705
|
import * as path8 from "path";
|
|
231148
|
-
import { DuckDBConnection as DuckDBConnection3 } from "@malloydata/db-duckdb";
|
|
231149
|
-
import"@malloydata/db-duckdb/native";
|
|
231150
230706
|
import {
|
|
231151
|
-
ConnectionRuntime,
|
|
231152
230707
|
contextOverlay as contextOverlay2,
|
|
231153
|
-
EmptyURLReader,
|
|
231154
230708
|
FixedConnectionMap as FixedConnectionMap2,
|
|
231155
230709
|
MalloyConfig as MalloyConfig3
|
|
231156
230710
|
} from "@malloydata/malloy";
|
|
231157
230711
|
|
|
231158
230712
|
// src/service/model.ts
|
|
231159
|
-
init_compile_pool();
|
|
231160
|
-
init_constants();
|
|
231161
230713
|
var import_api2 = __toESM(require_src(), 1);
|
|
231162
230714
|
import {
|
|
231163
230715
|
API,
|
|
@@ -231177,7 +230729,6 @@ import { createRequire as createRequire2 } from "module";
|
|
|
231177
230729
|
import * as path7 from "path";
|
|
231178
230730
|
|
|
231179
230731
|
// src/data_styles.ts
|
|
231180
|
-
init_logger();
|
|
231181
230732
|
function compileDataStyles(styles) {
|
|
231182
230733
|
try {
|
|
231183
230734
|
return JSON.parse(styles);
|
|
@@ -231224,10 +230775,6 @@ class HackyDataStylesAccumulator {
|
|
|
231224
230775
|
}
|
|
231225
230776
|
}
|
|
231226
230777
|
|
|
231227
|
-
// src/service/model.ts
|
|
231228
|
-
init_errors();
|
|
231229
|
-
init_logger();
|
|
231230
|
-
|
|
231231
230778
|
// src/service/filter.ts
|
|
231232
230779
|
var VALID_FILTER_TYPES = new Set([
|
|
231233
230780
|
"equal",
|
|
@@ -231436,8 +230983,6 @@ class Model {
|
|
|
231436
230983
|
dataStyles;
|
|
231437
230984
|
modelType;
|
|
231438
230985
|
modelMaterializer;
|
|
231439
|
-
materializerBuilder;
|
|
231440
|
-
materializerBuildPromise;
|
|
231441
230986
|
modelDef;
|
|
231442
230987
|
modelInfo;
|
|
231443
230988
|
sources;
|
|
@@ -231447,20 +230992,18 @@ class Model {
|
|
|
231447
230992
|
compilationError;
|
|
231448
230993
|
filterMap;
|
|
231449
230994
|
givens;
|
|
231450
|
-
cachedStandardModel;
|
|
231451
230995
|
meter = import_api2.metrics.getMeter("publisher");
|
|
231452
230996
|
queryExecutionHistogram = this.meter.createHistogram("malloy_model_query_duration", {
|
|
231453
230997
|
description: "How long it takes to execute a Malloy model query",
|
|
231454
230998
|
unit: "ms"
|
|
231455
230999
|
});
|
|
231456
|
-
constructor(packageName, modelPath, dataStyles, modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, compilationError, filterMap, givens
|
|
231000
|
+
constructor(packageName, modelPath, dataStyles, modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, compilationError, filterMap, givens) {
|
|
231457
231001
|
this.packageName = packageName;
|
|
231458
231002
|
this.modelPath = modelPath;
|
|
231459
231003
|
this.dataStyles = dataStyles;
|
|
231460
231004
|
this.modelType = modelType;
|
|
231461
231005
|
this.modelDef = modelDef;
|
|
231462
231006
|
this.modelMaterializer = modelMaterializer;
|
|
231463
|
-
this.materializerBuilder = materializerBuilder;
|
|
231464
231007
|
this.sources = sources;
|
|
231465
231008
|
this.queries = queries;
|
|
231466
231009
|
this.sourceInfos = sourceInfos;
|
|
@@ -231470,20 +231013,6 @@ class Model {
|
|
|
231470
231013
|
this.givens = givens;
|
|
231471
231014
|
this.modelInfo = this.modelDef ? modelDefToModelInfo(this.modelDef) : undefined;
|
|
231472
231015
|
}
|
|
231473
|
-
async ensureMaterializer() {
|
|
231474
|
-
if (this.modelMaterializer)
|
|
231475
|
-
return this.modelMaterializer;
|
|
231476
|
-
if (!this.materializerBuilder) {
|
|
231477
|
-
throw new BadRequestError("Model has no queryable entities.");
|
|
231478
|
-
}
|
|
231479
|
-
if (!this.materializerBuildPromise) {
|
|
231480
|
-
this.materializerBuildPromise = this.materializerBuilder().then((mm) => {
|
|
231481
|
-
this.modelMaterializer = mm;
|
|
231482
|
-
return mm;
|
|
231483
|
-
});
|
|
231484
|
-
}
|
|
231485
|
-
return this.materializerBuildPromise;
|
|
231486
|
-
}
|
|
231487
231016
|
getFilters(sourceName) {
|
|
231488
231017
|
return this.filterMap.get(sourceName) ?? [];
|
|
231489
231018
|
}
|
|
@@ -231495,40 +231024,6 @@ class Model {
|
|
|
231495
231024
|
return runMatch?.[1] ?? arrowMatch?.[1];
|
|
231496
231025
|
}
|
|
231497
231026
|
static async create(packageName, packagePath, modelPath, malloyConfig, options) {
|
|
231498
|
-
const pool = getCompilePool();
|
|
231499
|
-
if (pool.enabled && modelPath.endsWith(MODEL_FILE_SUFFIX)) {
|
|
231500
|
-
try {
|
|
231501
|
-
return await Model.createViaWorker(packageName, packagePath, modelPath, malloyConfig, pool, options);
|
|
231502
|
-
} catch (poolError) {
|
|
231503
|
-
if (poolError instanceof ModelCompilationError || poolError instanceof MalloyError2) {
|
|
231504
|
-
return Model.makeErrorModel(packageName, modelPath, poolError instanceof MalloyError2 ? new ModelCompilationError(poolError) : poolError);
|
|
231505
|
-
}
|
|
231506
|
-
logger.warn("Compile worker failed; falling back to in-process compile", { packageName, modelPath, error: poolError });
|
|
231507
|
-
}
|
|
231508
|
-
}
|
|
231509
|
-
return Model.createInProcess(packageName, packagePath, modelPath, malloyConfig, options);
|
|
231510
|
-
}
|
|
231511
|
-
static async createViaWorker(packageName, packagePath, modelPath, malloyConfig, pool, options) {
|
|
231512
|
-
const resolvedConfig = Model.toMalloyConfig(malloyConfig);
|
|
231513
|
-
const outcome = await pool.compile({
|
|
231514
|
-
packagePath,
|
|
231515
|
-
modelPath,
|
|
231516
|
-
malloyConfig: resolvedConfig,
|
|
231517
|
-
defaultConnectionName: "duckdb",
|
|
231518
|
-
urlReader: URL_READER,
|
|
231519
|
-
buildManifest: options?.buildManifest
|
|
231520
|
-
});
|
|
231521
|
-
const materializerBuilder = async () => {
|
|
231522
|
-
const { runtime, modelURL, importBaseURL } = await Model.getModelRuntime(packagePath, modelPath, malloyConfig, options);
|
|
231523
|
-
return Model.getStandardModelMaterializer(runtime, importBaseURL, modelURL, modelPath);
|
|
231524
|
-
};
|
|
231525
|
-
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);
|
|
231526
|
-
}
|
|
231527
|
-
static makeErrorModel(packageName, modelPath, error) {
|
|
231528
|
-
const isNotebook = modelPath.endsWith(NOTEBOOK_FILE_SUFFIX);
|
|
231529
|
-
return new Model(packageName, modelPath, {}, isNotebook ? "notebook" : "model", undefined, undefined, undefined, undefined, undefined, undefined, error);
|
|
231530
|
-
}
|
|
231531
|
-
static async createInProcess(packageName, packagePath, modelPath, malloyConfig, options) {
|
|
231532
231027
|
const { runtime, modelURL, importBaseURL, dataStyles, modelType } = await Model.getModelRuntime(packagePath, modelPath, malloyConfig, options);
|
|
231533
231028
|
try {
|
|
231534
231029
|
const { modelMaterializer, runnableNotebookCells } = await Model.getModelMaterializer(runtime, importBaseURL, modelURL, modelPath);
|
|
@@ -231639,18 +231134,8 @@ class Model {
|
|
|
231639
231134
|
throw new BadRequestError(`Model compilation failed: ${this.compilationError.message}`);
|
|
231640
231135
|
}
|
|
231641
231136
|
let runnable;
|
|
231642
|
-
if (!this.modelDef || !this.modelInfo)
|
|
231137
|
+
if (!this.modelMaterializer || !this.modelDef || !this.modelInfo)
|
|
231643
231138
|
throw new BadRequestError("Model has no queryable entities.");
|
|
231644
|
-
let materializer;
|
|
231645
|
-
try {
|
|
231646
|
-
materializer = await this.ensureMaterializer();
|
|
231647
|
-
} catch (error) {
|
|
231648
|
-
if (error instanceof BadRequestError)
|
|
231649
|
-
throw error;
|
|
231650
|
-
if (error instanceof MalloyError2)
|
|
231651
|
-
throw error;
|
|
231652
|
-
throw new BadRequestError(error instanceof Error ? `Failed to prepare model: ${error.message}` : "Failed to prepare model.");
|
|
231653
|
-
}
|
|
231654
231139
|
try {
|
|
231655
231140
|
let queryString;
|
|
231656
231141
|
if (!sourceName && !queryName && query) {
|
|
@@ -231681,7 +231166,7 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231681
231166
|
}
|
|
231682
231167
|
}
|
|
231683
231168
|
}
|
|
231684
|
-
runnable =
|
|
231169
|
+
runnable = this.modelMaterializer.loadQuery(queryString);
|
|
231685
231170
|
} catch (error) {
|
|
231686
231171
|
if (error instanceof BadRequestError) {
|
|
231687
231172
|
throw error;
|
|
@@ -231753,9 +231238,7 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231753
231238
|
};
|
|
231754
231239
|
}
|
|
231755
231240
|
getStandardModel() {
|
|
231756
|
-
|
|
231757
|
-
return this.cachedStandardModel;
|
|
231758
|
-
const compiled = {
|
|
231241
|
+
return {
|
|
231759
231242
|
type: "source",
|
|
231760
231243
|
packageName: this.packageName,
|
|
231761
231244
|
modelPath: this.modelPath,
|
|
@@ -231768,8 +231251,6 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
231768
231251
|
queries: this.queries,
|
|
231769
231252
|
givens: this.givens
|
|
231770
231253
|
};
|
|
231771
|
-
this.cachedStandardModel = compiled;
|
|
231772
|
-
return compiled;
|
|
231773
231254
|
}
|
|
231774
231255
|
async getNotebookModel() {
|
|
231775
231256
|
const notebookCells = this.runnableNotebookCells.map((cell) => {
|
|
@@ -232095,6 +231576,167 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
232095
231576
|
}
|
|
232096
231577
|
}
|
|
232097
231578
|
|
|
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
|
+
|
|
232098
231740
|
// src/service/package.ts
|
|
232099
231741
|
var ENABLE_LIST_MODEL_COMPILATION = true;
|
|
232100
231742
|
|
|
@@ -232128,6 +231770,7 @@ class Package {
|
|
|
232128
231770
|
packageName,
|
|
232129
231771
|
duration: formatDuration(manifestValidationTime - startTime)
|
|
232130
231772
|
});
|
|
231773
|
+
let packageMalloyConfig;
|
|
232131
231774
|
try {
|
|
232132
231775
|
const packageConfig = await Package.readPackageConfig(packagePath);
|
|
232133
231776
|
const packageConfigTime = performance.now();
|
|
@@ -232188,6 +231831,13 @@ class Package {
|
|
|
232188
231831
|
malloy_package_name: packageName,
|
|
232189
231832
|
status: "error"
|
|
232190
231833
|
});
|
|
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
|
+
}
|
|
232191
231841
|
try {
|
|
232192
231842
|
await fs5.rm(packagePath, {
|
|
232193
231843
|
recursive: true,
|
|
@@ -232349,14 +231999,29 @@ class Package {
|
|
|
232349
231999
|
};
|
|
232350
232000
|
}
|
|
232351
232001
|
static async readDatabases(packagePath) {
|
|
232352
|
-
|
|
232353
|
-
|
|
232354
|
-
return
|
|
232355
|
-
|
|
232356
|
-
|
|
232357
|
-
|
|
232358
|
-
|
|
232359
|
-
|
|
232002
|
+
const databasePaths = await Package.getDatabasePaths(packagePath);
|
|
232003
|
+
if (databasePaths.length === 0)
|
|
232004
|
+
return [];
|
|
232005
|
+
const pool = getSchemaWorkerPool();
|
|
232006
|
+
const settled = await Promise.allSettled(databasePaths.map((databasePath) => pool.submit(packagePath, databasePath)));
|
|
232007
|
+
const results = [];
|
|
232008
|
+
for (let i = 0;i < settled.length; i++) {
|
|
232009
|
+
const outcome = settled[i];
|
|
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;
|
|
232360
232025
|
}
|
|
232361
232026
|
static async getDatabasePaths(packagePath) {
|
|
232362
232027
|
const files = await import_recursive_readdir.default(packagePath, [ignoreDotfiles]);
|
|
@@ -232364,24 +232029,6 @@ class Package {
|
|
|
232364
232029
|
return path8.relative(packagePath, fullPath).replace(/\\/g, "/");
|
|
232365
232030
|
}).filter((modelPath) => modelPath.endsWith(".parquet") || modelPath.endsWith(".csv"));
|
|
232366
232031
|
}
|
|
232367
|
-
static async getDatabaseInfo(packagePath, databasePath) {
|
|
232368
|
-
const fullPath = path8.join(packagePath, databasePath);
|
|
232369
|
-
const runtime = new ConnectionRuntime({
|
|
232370
|
-
urlReader: new EmptyURLReader,
|
|
232371
|
-
connections: [new DuckDBConnection3("duckdb")]
|
|
232372
|
-
});
|
|
232373
|
-
const normalizedPath = fullPath.replace(/\\/g, "/");
|
|
232374
|
-
const model = runtime.loadModel(`source: temp is duckdb.table('${normalizedPath}')`);
|
|
232375
|
-
const modelDef = await model.getModel();
|
|
232376
|
-
const fields = modelDef._modelDef.contents["temp"].fields;
|
|
232377
|
-
const schema = fields.map((field) => {
|
|
232378
|
-
return { type: field.type, name: field.name };
|
|
232379
|
-
});
|
|
232380
|
-
const runner = model.loadQuery("run: temp->{aggregate: row_count is count()}");
|
|
232381
|
-
const result = await runner.run();
|
|
232382
|
-
const rowCount = result.data.value[0].row_count?.valueOf();
|
|
232383
|
-
return { name: databasePath, rowCount, columns: schema };
|
|
232384
|
-
}
|
|
232385
232032
|
setName(name) {
|
|
232386
232033
|
this.packageName = name;
|
|
232387
232034
|
}
|
|
@@ -233350,6 +232997,10 @@ class EnvironmentStore {
|
|
|
233350
232997
|
return Promise.all(Array.from(this.environments.values()).map((environment) => environment.serialize()));
|
|
233351
232998
|
}
|
|
233352
232999
|
async getStatus() {
|
|
233000
|
+
const memoryGovernorStatus = this.memoryGovernor?.getStatus() ?? null;
|
|
233001
|
+
logger.info("Memory governor status", {
|
|
233002
|
+
memoryGovernor: memoryGovernorStatus
|
|
233003
|
+
});
|
|
233353
233004
|
const status = {
|
|
233354
233005
|
timestamp: Date.now(),
|
|
233355
233006
|
environments: [],
|
|
@@ -233993,12 +233644,7 @@ class WatchModeController {
|
|
|
233993
233644
|
};
|
|
233994
233645
|
}
|
|
233995
233646
|
|
|
233996
|
-
// src/server.ts
|
|
233997
|
-
init_errors();
|
|
233998
|
-
init_logger();
|
|
233999
|
-
|
|
234000
233647
|
// src/service/resolve_environment.ts
|
|
234001
|
-
init_errors();
|
|
234002
233648
|
async function resolveEnvironmentId(repository, environmentName) {
|
|
234003
233649
|
const dbEnvironment = await repository.getEnvironmentByName(environmentName);
|
|
234004
233650
|
if (!dbEnvironment) {
|
|
@@ -234030,8 +233676,6 @@ class ManifestController {
|
|
|
234030
233676
|
}
|
|
234031
233677
|
|
|
234032
233678
|
// src/controller/materialization.controller.ts
|
|
234033
|
-
init_errors();
|
|
234034
|
-
|
|
234035
233679
|
class MaterializationController {
|
|
234036
233680
|
materializationService;
|
|
234037
233681
|
constructor(materializationService) {
|
|
@@ -236718,12 +236362,6 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
236718
236362
|
}
|
|
236719
236363
|
};
|
|
236720
236364
|
|
|
236721
|
-
// src/mcp/server.ts
|
|
236722
|
-
init_logger();
|
|
236723
|
-
|
|
236724
|
-
// src/mcp/prompts/prompt_service.ts
|
|
236725
|
-
init_logger();
|
|
236726
|
-
|
|
236727
236365
|
// src/mcp/prompts/handlers.ts
|
|
236728
236366
|
var import_handlebars = __toESM(require_lib8(), 1);
|
|
236729
236367
|
|
|
@@ -236918,9 +236556,6 @@ function registerPromptCapability(mcpServer, environmentStore) {
|
|
|
236918
236556
|
logger.info(`[MCP Init] Finished registering prompts. Registered: ${registeredCount}`, { duration: endTime - startTime });
|
|
236919
236557
|
}
|
|
236920
236558
|
|
|
236921
|
-
// src/mcp/resources/environment_resource.ts
|
|
236922
|
-
init_logger();
|
|
236923
|
-
|
|
236924
236559
|
// src/mcp/error_messages.ts
|
|
236925
236560
|
function getNotFoundError(resourceUriOrContext) {
|
|
236926
236561
|
const baseMessage = `Resource not found: ${resourceUriOrContext}`;
|
|
@@ -237010,9 +236645,6 @@ function getMalloyErrorDetails(operation, modelIdentifier, error) {
|
|
|
237010
236645
|
}
|
|
237011
236646
|
|
|
237012
236647
|
// src/mcp/handler_utils.ts
|
|
237013
|
-
init_errors();
|
|
237014
|
-
init_logger();
|
|
237015
|
-
|
|
237016
236648
|
class McpGetResourceError extends Error {
|
|
237017
236649
|
details;
|
|
237018
236650
|
constructor(details) {
|
|
@@ -237225,7 +236857,6 @@ function registerEnvironmentResource(mcpServer, environmentStore) {
|
|
|
237225
236857
|
}
|
|
237226
236858
|
|
|
237227
236859
|
// src/mcp/resources/model_resource.ts
|
|
237228
|
-
init_errors();
|
|
237229
236860
|
function registerModelResource(mcpServer, environmentStore) {
|
|
237230
236861
|
mcpServer.resource("model", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "model", async ({
|
|
237231
236862
|
environmentName,
|
|
@@ -237285,8 +236916,6 @@ function registerModelResource(mcpServer, environmentStore) {
|
|
|
237285
236916
|
}
|
|
237286
236917
|
|
|
237287
236918
|
// src/mcp/resources/notebook_resource.ts
|
|
237288
|
-
init_errors();
|
|
237289
|
-
init_logger();
|
|
237290
236919
|
function registerNotebookResource(mcpServer, environmentStore) {
|
|
237291
236920
|
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) => {
|
|
237292
236921
|
if (typeof environmentName !== "string" || typeof packageName !== "string" || typeof notebookName !== "string") {
|
|
@@ -237326,8 +236955,6 @@ function registerNotebookResource(mcpServer, environmentStore) {
|
|
|
237326
236955
|
}
|
|
237327
236956
|
|
|
237328
236957
|
// src/mcp/resources/package_resource.ts
|
|
237329
|
-
init_errors();
|
|
237330
|
-
init_logger();
|
|
237331
236958
|
async function handleGetPackageContents(uri, params, environmentStore) {
|
|
237332
236959
|
try {
|
|
237333
236960
|
const { environmentName, packageName } = params;
|
|
@@ -237520,8 +237147,6 @@ function registerPackageResource(mcpServer, environmentStore) {
|
|
|
237520
237147
|
}
|
|
237521
237148
|
|
|
237522
237149
|
// src/mcp/resources/query_resource.ts
|
|
237523
|
-
init_errors();
|
|
237524
|
-
init_logger();
|
|
237525
237150
|
function registerQueryResource(mcpServer, environmentStore) {
|
|
237526
237151
|
mcpServer.resource("query", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/queries/{queryName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "query", async ({
|
|
237527
237152
|
environmentName,
|
|
@@ -237564,8 +237189,6 @@ function registerQueryResource(mcpServer, environmentStore) {
|
|
|
237564
237189
|
}
|
|
237565
237190
|
|
|
237566
237191
|
// src/mcp/resources/source_resource.ts
|
|
237567
|
-
init_errors();
|
|
237568
|
-
init_logger();
|
|
237569
237192
|
function registerSourceResource(mcpServer, environmentStore) {
|
|
237570
237193
|
mcpServer.resource("source", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/sources/{sourceName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "source", async ({
|
|
237571
237194
|
environmentName,
|
|
@@ -237611,8 +237234,6 @@ function registerSourceResource(mcpServer, environmentStore) {
|
|
|
237611
237234
|
}
|
|
237612
237235
|
|
|
237613
237236
|
// src/mcp/resources/view_resource.ts
|
|
237614
|
-
init_errors();
|
|
237615
|
-
init_logger();
|
|
237616
237237
|
function registerViewResource(mcpServer, environmentStore) {
|
|
237617
237238
|
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 ({
|
|
237618
237239
|
environmentName,
|
|
@@ -237810,9 +237431,6 @@ function registerTools(mcpServer, environmentStore) {
|
|
|
237810
237431
|
});
|
|
237811
237432
|
}
|
|
237812
237433
|
|
|
237813
|
-
// src/mcp/tools/execute_query_tool.ts
|
|
237814
|
-
init_logger();
|
|
237815
|
-
|
|
237816
237434
|
// src/mcp/mcp_constants.ts
|
|
237817
237435
|
var MCP_ERROR_MESSAGES = {
|
|
237818
237436
|
MISSING_REQUIRED_PARAMS: "Either 'query' or both 'sourceName' and 'queryName' must be provided",
|
|
@@ -238019,8 +237637,6 @@ function initializeMcpServer(environmentStore) {
|
|
|
238019
237637
|
}
|
|
238020
237638
|
|
|
238021
237639
|
// src/server-old.ts
|
|
238022
|
-
init_errors();
|
|
238023
|
-
init_logger();
|
|
238024
237640
|
var import_body_parser = __toESM(require_body_parser(), 1);
|
|
238025
237641
|
var LEGACY_API_PREFIX = "/api/v0";
|
|
238026
237642
|
function remapMaterializationResponse(mat) {
|
|
@@ -238596,8 +238212,6 @@ function registerLegacyRoutes(app, controllers) {
|
|
|
238596
238212
|
}
|
|
238597
238213
|
|
|
238598
238214
|
// src/service/manifest_service.ts
|
|
238599
|
-
init_logger();
|
|
238600
|
-
|
|
238601
238215
|
class ManifestService {
|
|
238602
238216
|
environmentStore;
|
|
238603
238217
|
constructor(environmentStore) {
|
|
@@ -238633,12 +238247,9 @@ class ManifestService {
|
|
|
238633
238247
|
}
|
|
238634
238248
|
|
|
238635
238249
|
// src/service/materialization_service.ts
|
|
238636
|
-
init_errors();
|
|
238637
|
-
init_logger();
|
|
238638
238250
|
import { Manifest } from "@malloydata/malloy";
|
|
238639
238251
|
|
|
238640
238252
|
// src/service/materialized_table_gc.ts
|
|
238641
|
-
init_logger();
|
|
238642
238253
|
import {
|
|
238643
238254
|
DatabricksDialect,
|
|
238644
238255
|
DuckDBDialect,
|
|
@@ -239240,7 +238851,6 @@ class MaterializationService {
|
|
|
239240
238851
|
}
|
|
239241
238852
|
|
|
239242
238853
|
// src/service/package_memory_governor.ts
|
|
239243
|
-
init_logger();
|
|
239244
238854
|
var import_api4 = __toESM(require_src(), 1);
|
|
239245
238855
|
var DEFAULT_RSS_SAMPLER = () => process.memoryUsage().rss;
|
|
239246
238856
|
|
|
@@ -239341,6 +238951,118 @@ class PackageMemoryGovernor {
|
|
|
239341
238951
|
}
|
|
239342
238952
|
}
|
|
239343
238953
|
|
|
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
|
+
|
|
239344
239066
|
// src/server.ts
|
|
239345
239067
|
function normalizeQueryArray(value) {
|
|
239346
239068
|
if (value === undefined || value === null)
|
|
@@ -239409,7 +239131,7 @@ var MCP_PORT = Number(process.env.MCP_PORT || 4040);
|
|
|
239409
239131
|
var MCP_ENDPOINT = "/mcp";
|
|
239410
239132
|
var SHUTDOWN_DRAIN_DURATION_SECONDS = Number(process.env.SHUTDOWN_DRAIN_DURATION_SECONDS || 0);
|
|
239411
239133
|
var SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS = Number(process.env.SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS || 0);
|
|
239412
|
-
var __filename_esm =
|
|
239134
|
+
var __filename_esm = fileURLToPath3(import.meta.url);
|
|
239413
239135
|
var ROOT = path12.join(path12.dirname(__filename_esm), "app");
|
|
239414
239136
|
var SERVER_ROOT = path12.resolve(process.cwd(), process.env.SERVER_ROOT || ".");
|
|
239415
239137
|
var API_PREFIX2 = "/api/v0";
|
|
@@ -239426,6 +239148,8 @@ var memoryGovernorConfig = getMemoryGovernorConfig();
|
|
|
239426
239148
|
var memoryGovernor = memoryGovernorConfig ? new PackageMemoryGovernor(memoryGovernorConfig) : null;
|
|
239427
239149
|
memoryGovernor?.start();
|
|
239428
239150
|
environmentStore.setMemoryGovernor(memoryGovernor);
|
|
239151
|
+
var processStatsReporter = new ProcessStatsReporter(memoryGovernor);
|
|
239152
|
+
processStatsReporter.start();
|
|
239429
239153
|
var packageController = new PackageController(environmentStore, manifestService);
|
|
239430
239154
|
var databaseController = new DatabaseController(environmentStore);
|
|
239431
239155
|
var queryController = new QueryController(environmentStore);
|