@malloy-publisher/server 0.0.198-dev3 → 0.0.198-dev6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.ts +26 -12
- package/dist/instrumentation.mjs +37 -37
- package/dist/package_load_worker.mjs +12213 -0
- package/dist/server.mjs +1091 -706
- package/package.json +1 -1
- package/src/health.ts +15 -0
- package/src/package_load/package_load_pool.spec.ts +252 -0
- package/src/package_load/package_load_pool.ts +920 -0
- package/src/package_load/package_load_worker.ts +980 -0
- package/src/package_load/protocol.ts +336 -0
- package/src/server.ts +12 -5
- package/src/service/environment_store.ts +0 -9
- package/src/service/given.ts +80 -0
- package/src/service/model.ts +253 -66
- package/src/service/package.spec.ts +17 -11
- package/src/service/package.ts +294 -178
- package/src/service/package_worker_path.spec.ts +196 -0
- package/dist/service/schema_worker.mjs +0 -61
- package/src/service/process_stats_reporter.ts +0 -169
- package/src/service/schema_worker.ts +0 -123
- package/src/service/schema_worker_pool.ts +0 -287
- package/tests/integration/concurrent_environment/concurrent_environment.integration.spec.ts +0 -235
package/dist/server.mjs
CHANGED
|
@@ -44,6 +44,7 @@ var __export = (target, all) => {
|
|
|
44
44
|
set: __exportSetter.bind(all, name)
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
47
48
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
48
49
|
|
|
49
50
|
// ../../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
@@ -115087,6 +115088,91 @@ var require_winston = __commonJS((exports) => {
|
|
|
115087
115088
|
warn.forProperties(exports, "deprecated", ["emitErrs", "levelLength"]);
|
|
115088
115089
|
});
|
|
115089
115090
|
|
|
115091
|
+
// src/logger.ts
|
|
115092
|
+
function extractTraceIdFromTraceparent(traceparent) {
|
|
115093
|
+
if (!traceparent) {
|
|
115094
|
+
return;
|
|
115095
|
+
}
|
|
115096
|
+
const parts = traceparent.split("-");
|
|
115097
|
+
const traceId = parts.length >= 2 ? parts[1] : parts.length == 1 ? parts[0] : undefined;
|
|
115098
|
+
if (traceId && traceId.length === 32 && /^[0-9a-fA-F]{32}$/.test(traceId)) {
|
|
115099
|
+
return traceId;
|
|
115100
|
+
}
|
|
115101
|
+
return;
|
|
115102
|
+
}
|
|
115103
|
+
function formatDuration(durationMs) {
|
|
115104
|
+
if (durationMs >= 1000) {
|
|
115105
|
+
const seconds = durationMs / 1000;
|
|
115106
|
+
return `${seconds.toFixed(2)}s`;
|
|
115107
|
+
}
|
|
115108
|
+
return `${durationMs.toFixed(2)}ms`;
|
|
115109
|
+
}
|
|
115110
|
+
var import_winston, isTelemetryEnabled, VALID_LOG_LEVELS, getLogLevel = () => {
|
|
115111
|
+
if (process.env.LOG_LEVEL) {
|
|
115112
|
+
const logLevel = process.env.LOG_LEVEL.toLowerCase();
|
|
115113
|
+
if (VALID_LOG_LEVELS.includes(logLevel)) {
|
|
115114
|
+
return logLevel;
|
|
115115
|
+
} else {
|
|
115116
|
+
console.error(`Invalid log level: ${process.env.LOG_LEVEL}. Valid log levels are: ${VALID_LOG_LEVELS.join(", ")}. Defaulting to "debug".`);
|
|
115117
|
+
}
|
|
115118
|
+
}
|
|
115119
|
+
return "debug";
|
|
115120
|
+
}, logger, DISABLE_RESPONSE_LOGGING, loggerMiddleware = (req, res, next) => {
|
|
115121
|
+
const startTime = performance.now();
|
|
115122
|
+
const resJson = res.json;
|
|
115123
|
+
res.json = (body) => {
|
|
115124
|
+
res.locals.body = body;
|
|
115125
|
+
return resJson.call(res, body);
|
|
115126
|
+
};
|
|
115127
|
+
res.on("finish", () => {
|
|
115128
|
+
const endTime = performance.now();
|
|
115129
|
+
const durationMs = endTime - startTime;
|
|
115130
|
+
const traceparent = req.headers["traceparent"];
|
|
115131
|
+
const traceId = extractTraceIdFromTraceparent(traceparent);
|
|
115132
|
+
const logMetadata = {
|
|
115133
|
+
statusCode: res.statusCode,
|
|
115134
|
+
duration: formatDuration(durationMs),
|
|
115135
|
+
payload: req.body,
|
|
115136
|
+
params: req.params,
|
|
115137
|
+
query: req.query
|
|
115138
|
+
};
|
|
115139
|
+
if (!DISABLE_RESPONSE_LOGGING) {
|
|
115140
|
+
logMetadata.response = res.locals.body;
|
|
115141
|
+
}
|
|
115142
|
+
if (traceId) {
|
|
115143
|
+
logMetadata.traceId = traceId;
|
|
115144
|
+
}
|
|
115145
|
+
if (req.url !== "/metrics" && req.url !== "/health" && req.url !== "/health/liveness" && req.url !== "/health/readiness") {
|
|
115146
|
+
logger.info(`${req.method} ${req.url}`, logMetadata);
|
|
115147
|
+
}
|
|
115148
|
+
});
|
|
115149
|
+
next();
|
|
115150
|
+
}, logAxiosError = (error) => {
|
|
115151
|
+
if (error.response) {
|
|
115152
|
+
logger.error("Axios server-side error", {
|
|
115153
|
+
url: error.response.config.url,
|
|
115154
|
+
status: error.response.status,
|
|
115155
|
+
headers: error.response.headers,
|
|
115156
|
+
data: error.response.data
|
|
115157
|
+
});
|
|
115158
|
+
} else if (error.request) {
|
|
115159
|
+
logger.error("Axios client-side error", { error: error.request });
|
|
115160
|
+
} else {
|
|
115161
|
+
logger.error("Axios unknown error", { error });
|
|
115162
|
+
}
|
|
115163
|
+
};
|
|
115164
|
+
var init_logger = __esm(() => {
|
|
115165
|
+
import_winston = __toESM(require_winston(), 1);
|
|
115166
|
+
isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
|
|
115167
|
+
VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
|
|
115168
|
+
logger = import_winston.default.createLogger({
|
|
115169
|
+
level: getLogLevel(),
|
|
115170
|
+
format: isTelemetryEnabled ? import_winston.default.format.combine(import_winston.default.format.uncolorize(), import_winston.default.format.timestamp(), import_winston.default.format.errors({ stack: true }), import_winston.default.format.json()) : import_winston.default.format.combine(import_winston.default.format.colorize(), import_winston.default.format.simple()),
|
|
115171
|
+
transports: [new import_winston.default.transports.Console]
|
|
115172
|
+
});
|
|
115173
|
+
DISABLE_RESPONSE_LOGGING = process.env.DISABLE_RESPONSE_LOGGING === "true" || process.env.DISABLE_RESPONSE_LOGGING === "1";
|
|
115174
|
+
});
|
|
115175
|
+
|
|
115090
115176
|
// ../../node_modules/bytes/index.js
|
|
115091
115177
|
var require_bytes = __commonJS((exports, module) => {
|
|
115092
115178
|
/*!
|
|
@@ -147228,6 +147314,132 @@ var require_dist4 = __commonJS((exports) => {
|
|
|
147228
147314
|
__exportStar(require_legacy2(), exports);
|
|
147229
147315
|
});
|
|
147230
147316
|
|
|
147317
|
+
// src/constants.ts
|
|
147318
|
+
import os from "os";
|
|
147319
|
+
var API_PREFIX = "/api/v0", README_NAME = "README.md", PUBLISHER_CONFIG_NAME = "publisher.config.json", PACKAGE_MANIFEST_NAME = "publisher.json", MODEL_FILE_SUFFIX = ".malloy", NOTEBOOK_FILE_SUFFIX = ".malloynb", ROW_LIMIT = 1000, TEMP_DIR_PATH, PUBLISHER_DATA_DIR = "publisher_data";
|
|
147320
|
+
var init_constants = __esm(() => {
|
|
147321
|
+
TEMP_DIR_PATH = os.tmpdir();
|
|
147322
|
+
});
|
|
147323
|
+
|
|
147324
|
+
// src/errors.ts
|
|
147325
|
+
import { MalloyError } from "@malloydata/malloy";
|
|
147326
|
+
function internalErrorToHttpError(error) {
|
|
147327
|
+
if (error instanceof BadRequestError) {
|
|
147328
|
+
return httpError(400, error.message);
|
|
147329
|
+
} else if (error instanceof FrozenConfigError) {
|
|
147330
|
+
return httpError(403, error.message);
|
|
147331
|
+
} else if (error instanceof EnvironmentNotFoundError) {
|
|
147332
|
+
return httpError(404, error.message);
|
|
147333
|
+
} else if (error instanceof PackageNotFoundError) {
|
|
147334
|
+
return httpError(404, error.message);
|
|
147335
|
+
} else if (error instanceof ModelNotFoundError) {
|
|
147336
|
+
return httpError(404, error.message);
|
|
147337
|
+
} else if (error instanceof MalloyError) {
|
|
147338
|
+
return httpError(400, error.message);
|
|
147339
|
+
} else if (error instanceof ConnectionNotFoundError) {
|
|
147340
|
+
return httpError(404, error.message);
|
|
147341
|
+
} else if (error instanceof ConnectionAuthError) {
|
|
147342
|
+
return httpError(422, error.message);
|
|
147343
|
+
} else if (error instanceof ModelCompilationError) {
|
|
147344
|
+
return httpError(424, error.message);
|
|
147345
|
+
} else if (error instanceof ConnectionError) {
|
|
147346
|
+
return httpError(502, error.message);
|
|
147347
|
+
} else if (error instanceof MaterializationNotFoundError) {
|
|
147348
|
+
return httpError(404, error.message);
|
|
147349
|
+
} else if (error instanceof MaterializationConflictError) {
|
|
147350
|
+
return httpError(409, error.message);
|
|
147351
|
+
} else if (error instanceof InvalidStateTransitionError) {
|
|
147352
|
+
return httpError(409, error.message);
|
|
147353
|
+
} else if (error instanceof ServiceUnavailableError) {
|
|
147354
|
+
return httpError(503, error.message);
|
|
147355
|
+
} else {
|
|
147356
|
+
return httpError(500, error.message);
|
|
147357
|
+
}
|
|
147358
|
+
}
|
|
147359
|
+
function httpError(code, message) {
|
|
147360
|
+
return {
|
|
147361
|
+
status: code,
|
|
147362
|
+
json: {
|
|
147363
|
+
code,
|
|
147364
|
+
message
|
|
147365
|
+
}
|
|
147366
|
+
};
|
|
147367
|
+
}
|
|
147368
|
+
var NotImplementedError, BadRequestError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, ConnectionNotFoundError, ConnectionError, ConnectionAuthError, ModelCompilationError, FrozenConfigError, MaterializationNotFoundError, MaterializationConflictError, InvalidStateTransitionError, ServiceUnavailableError;
|
|
147369
|
+
var init_errors = __esm(() => {
|
|
147370
|
+
init_constants();
|
|
147371
|
+
NotImplementedError = class NotImplementedError extends Error {
|
|
147372
|
+
constructor(message) {
|
|
147373
|
+
super(message);
|
|
147374
|
+
}
|
|
147375
|
+
};
|
|
147376
|
+
BadRequestError = class BadRequestError extends Error {
|
|
147377
|
+
constructor(message) {
|
|
147378
|
+
super(message);
|
|
147379
|
+
}
|
|
147380
|
+
};
|
|
147381
|
+
EnvironmentNotFoundError = class EnvironmentNotFoundError extends Error {
|
|
147382
|
+
constructor(message) {
|
|
147383
|
+
super(message);
|
|
147384
|
+
}
|
|
147385
|
+
};
|
|
147386
|
+
PackageNotFoundError = class PackageNotFoundError extends Error {
|
|
147387
|
+
constructor(message) {
|
|
147388
|
+
super(message);
|
|
147389
|
+
}
|
|
147390
|
+
};
|
|
147391
|
+
ModelNotFoundError = class ModelNotFoundError extends Error {
|
|
147392
|
+
constructor(message) {
|
|
147393
|
+
super(message);
|
|
147394
|
+
}
|
|
147395
|
+
};
|
|
147396
|
+
ConnectionNotFoundError = class ConnectionNotFoundError extends Error {
|
|
147397
|
+
constructor(message) {
|
|
147398
|
+
super(message);
|
|
147399
|
+
}
|
|
147400
|
+
};
|
|
147401
|
+
ConnectionError = class ConnectionError extends Error {
|
|
147402
|
+
constructor(message) {
|
|
147403
|
+
super(message);
|
|
147404
|
+
}
|
|
147405
|
+
};
|
|
147406
|
+
ConnectionAuthError = class ConnectionAuthError extends Error {
|
|
147407
|
+
constructor(message) {
|
|
147408
|
+
super(message);
|
|
147409
|
+
}
|
|
147410
|
+
};
|
|
147411
|
+
ModelCompilationError = class ModelCompilationError extends Error {
|
|
147412
|
+
constructor(error) {
|
|
147413
|
+
super(error.message);
|
|
147414
|
+
}
|
|
147415
|
+
};
|
|
147416
|
+
FrozenConfigError = class FrozenConfigError extends Error {
|
|
147417
|
+
constructor(message = `Publisher config can't be updated when ${PUBLISHER_CONFIG_NAME} has { "frozenConfig": true }`) {
|
|
147418
|
+
super(message);
|
|
147419
|
+
}
|
|
147420
|
+
};
|
|
147421
|
+
MaterializationNotFoundError = class MaterializationNotFoundError extends Error {
|
|
147422
|
+
constructor(message) {
|
|
147423
|
+
super(message);
|
|
147424
|
+
}
|
|
147425
|
+
};
|
|
147426
|
+
MaterializationConflictError = class MaterializationConflictError extends Error {
|
|
147427
|
+
constructor(message) {
|
|
147428
|
+
super(message);
|
|
147429
|
+
}
|
|
147430
|
+
};
|
|
147431
|
+
InvalidStateTransitionError = class InvalidStateTransitionError extends Error {
|
|
147432
|
+
constructor(message) {
|
|
147433
|
+
super(message);
|
|
147434
|
+
}
|
|
147435
|
+
};
|
|
147436
|
+
ServiceUnavailableError = class ServiceUnavailableError extends Error {
|
|
147437
|
+
constructor(message) {
|
|
147438
|
+
super(message);
|
|
147439
|
+
}
|
|
147440
|
+
};
|
|
147441
|
+
});
|
|
147442
|
+
|
|
147231
147443
|
// ../../node_modules/delayed-stream/lib/delayed_stream.js
|
|
147232
147444
|
var require_delayed_stream = __commonJS((exports, module) => {
|
|
147233
147445
|
var Stream = __require("stream").Stream;
|
|
@@ -198501,6 +198713,504 @@ var require_dist12 = __commonJS((exports) => {
|
|
|
198501
198713
|
exports.default = deferred;
|
|
198502
198714
|
});
|
|
198503
198715
|
|
|
198716
|
+
// src/package_load/package_load_pool.ts
|
|
198717
|
+
var exports_package_load_pool = {};
|
|
198718
|
+
__export(exports_package_load_pool, {
|
|
198719
|
+
getPackageLoadWorkerCount: () => getPackageLoadWorkerCount,
|
|
198720
|
+
getPackageLoadPool: () => getPackageLoadPool,
|
|
198721
|
+
deserializeError: () => deserializeError,
|
|
198722
|
+
__setPackageLoadPoolForTests: () => __setPackageLoadPoolForTests,
|
|
198723
|
+
PackageLoadPool: () => PackageLoadPool
|
|
198724
|
+
});
|
|
198725
|
+
import { Worker } from "node:worker_threads";
|
|
198726
|
+
import { dirname as dirname3, join as join3 } from "path";
|
|
198727
|
+
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "url";
|
|
198728
|
+
function getPackageLoadWorkerCount() {
|
|
198729
|
+
const raw = process.env.PACKAGE_LOAD_WORKERS;
|
|
198730
|
+
if (raw === undefined)
|
|
198731
|
+
return 1;
|
|
198732
|
+
const parsed = Number.parseInt(raw, 10);
|
|
198733
|
+
if (!Number.isFinite(parsed) || parsed < 1) {
|
|
198734
|
+
throw new Error(`PACKAGE_LOAD_WORKERS must be a positive integer (got ${JSON.stringify(raw)}). ` + `Refusing to start without a package-load worker pool.`);
|
|
198735
|
+
}
|
|
198736
|
+
return parsed;
|
|
198737
|
+
}
|
|
198738
|
+
function resolveWorkerScript() {
|
|
198739
|
+
const thisFile = fileURLToPath2(import.meta.url);
|
|
198740
|
+
const thisDir = dirname3(thisFile);
|
|
198741
|
+
const distCandidate = join3(thisDir, "package_load_worker.mjs");
|
|
198742
|
+
if (thisFile.endsWith(".mjs") || thisFile.endsWith(".js")) {
|
|
198743
|
+
return pathToFileURL(distCandidate);
|
|
198744
|
+
}
|
|
198745
|
+
const tsCandidate = join3(thisDir, "package_load_worker.ts");
|
|
198746
|
+
return pathToFileURL(tsCandidate);
|
|
198747
|
+
}
|
|
198748
|
+
|
|
198749
|
+
class PackageLoadPool {
|
|
198750
|
+
workers = [];
|
|
198751
|
+
queue = [];
|
|
198752
|
+
jobs = new Map;
|
|
198753
|
+
maxWorkers;
|
|
198754
|
+
nextWorkerId = 0;
|
|
198755
|
+
nextJobId = 0;
|
|
198756
|
+
shuttingDown = false;
|
|
198757
|
+
workerScript;
|
|
198758
|
+
constructor(maxWorkers, workerScript) {
|
|
198759
|
+
if (!Number.isFinite(maxWorkers) || maxWorkers < 1) {
|
|
198760
|
+
throw new Error(`PackageLoadPool requires maxWorkers >= 1 (got ${maxWorkers}). ` + `The in-process compile fallback was removed in favour of a hard ` + `dependency on the worker pool; see getPackageLoadWorkerCount().`);
|
|
198761
|
+
}
|
|
198762
|
+
this.maxWorkers = maxWorkers;
|
|
198763
|
+
this.workerScript = workerScript ?? resolveWorkerScript();
|
|
198764
|
+
}
|
|
198765
|
+
get size() {
|
|
198766
|
+
return this.workers.filter((w) => !w.exited).length;
|
|
198767
|
+
}
|
|
198768
|
+
async loadPackage(request) {
|
|
198769
|
+
if (this.shuttingDown) {
|
|
198770
|
+
throw new Error("PackageLoadPool is shutting down");
|
|
198771
|
+
}
|
|
198772
|
+
return new Promise((resolve3, reject) => {
|
|
198773
|
+
this.queue.push({ request, resolve: resolve3, reject });
|
|
198774
|
+
this.tryDispatch();
|
|
198775
|
+
});
|
|
198776
|
+
}
|
|
198777
|
+
async shutdown() {
|
|
198778
|
+
if (this.shuttingDown)
|
|
198779
|
+
return;
|
|
198780
|
+
this.shuttingDown = true;
|
|
198781
|
+
const queued = this.queue.splice(0, this.queue.length);
|
|
198782
|
+
for (const qj of queued) {
|
|
198783
|
+
qj.reject(new Error("PackageLoadPool: shutdown before dispatch"));
|
|
198784
|
+
}
|
|
198785
|
+
const exits = this.workers.map((pw) => new Promise((resolve3) => {
|
|
198786
|
+
if (pw.exited) {
|
|
198787
|
+
resolve3();
|
|
198788
|
+
return;
|
|
198789
|
+
}
|
|
198790
|
+
pw.worker.once("exit", () => resolve3());
|
|
198791
|
+
const msg = { type: "shutdown" };
|
|
198792
|
+
pw.worker.postMessage(msg);
|
|
198793
|
+
setTimeout(() => {
|
|
198794
|
+
if (!pw.exited) {
|
|
198795
|
+
pw.worker.terminate().finally(() => resolve3());
|
|
198796
|
+
}
|
|
198797
|
+
}, 1e4);
|
|
198798
|
+
}));
|
|
198799
|
+
await Promise.all(exits);
|
|
198800
|
+
}
|
|
198801
|
+
tryDispatch() {
|
|
198802
|
+
if (this.shuttingDown)
|
|
198803
|
+
return;
|
|
198804
|
+
while (this.queue.length > 0) {
|
|
198805
|
+
const worker = this.findIdleOrSpawnable();
|
|
198806
|
+
if (!worker)
|
|
198807
|
+
return;
|
|
198808
|
+
const qj = this.queue.shift();
|
|
198809
|
+
if (!qj)
|
|
198810
|
+
return;
|
|
198811
|
+
this.dispatchToWorker(worker, qj);
|
|
198812
|
+
}
|
|
198813
|
+
}
|
|
198814
|
+
findIdleOrSpawnable() {
|
|
198815
|
+
const alive = this.workers.filter((w) => !w.exited);
|
|
198816
|
+
const idle = alive.find((w) => w.inFlight.size === 0);
|
|
198817
|
+
if (idle)
|
|
198818
|
+
return idle;
|
|
198819
|
+
if (alive.length < this.maxWorkers) {
|
|
198820
|
+
const pw = this.spawnWorker();
|
|
198821
|
+
this.workers.push(pw);
|
|
198822
|
+
return pw;
|
|
198823
|
+
}
|
|
198824
|
+
return null;
|
|
198825
|
+
}
|
|
198826
|
+
async dispatchToWorker(pw, qj) {
|
|
198827
|
+
try {
|
|
198828
|
+
await pw.ready;
|
|
198829
|
+
} catch (err) {
|
|
198830
|
+
qj.reject(err);
|
|
198831
|
+
this.tryDispatch();
|
|
198832
|
+
return;
|
|
198833
|
+
}
|
|
198834
|
+
this.nextJobId += 1;
|
|
198835
|
+
const jobId = `job-${this.nextJobId}`;
|
|
198836
|
+
const timeout = setTimeout(() => {
|
|
198837
|
+
this.handleJobTimeout(pw, jobId, qj.request.packagePath);
|
|
198838
|
+
}, PACKAGE_LOAD_JOB_TIMEOUT_MS);
|
|
198839
|
+
this.jobs.set(jobId, {
|
|
198840
|
+
jobId,
|
|
198841
|
+
pw,
|
|
198842
|
+
connections: qj.request.malloyConfig.connections,
|
|
198843
|
+
urlReader: qj.request.urlReader ?? defaultUrlReader,
|
|
198844
|
+
resolve: (result) => {
|
|
198845
|
+
clearTimeout(timeout);
|
|
198846
|
+
qj.resolve(adaptResult(result));
|
|
198847
|
+
},
|
|
198848
|
+
reject: (err) => {
|
|
198849
|
+
clearTimeout(timeout);
|
|
198850
|
+
qj.reject(err);
|
|
198851
|
+
},
|
|
198852
|
+
timeout
|
|
198853
|
+
});
|
|
198854
|
+
pw.inFlight.add(jobId);
|
|
198855
|
+
const message = {
|
|
198856
|
+
type: "load-package",
|
|
198857
|
+
requestId: jobId,
|
|
198858
|
+
packagePath: qj.request.packagePath,
|
|
198859
|
+
packageName: qj.request.packageName,
|
|
198860
|
+
defaultConnectionName: qj.request.defaultConnectionName,
|
|
198861
|
+
buildManifest: qj.request.buildManifest
|
|
198862
|
+
};
|
|
198863
|
+
pw.worker.postMessage(message);
|
|
198864
|
+
}
|
|
198865
|
+
handleJobTimeout(pw, jobId, packagePath) {
|
|
198866
|
+
logger.error(`PackageLoadPool: job ${jobId} (${packagePath}) timed out after ${PACKAGE_LOAD_JOB_TIMEOUT_MS}ms; terminating worker #${pw.id}`);
|
|
198867
|
+
this.failJob(jobId, new Error(`Package-load worker timed out after ${PACKAGE_LOAD_JOB_TIMEOUT_MS}ms (package=${packagePath})`));
|
|
198868
|
+
pw.worker.terminate();
|
|
198869
|
+
}
|
|
198870
|
+
spawnWorker() {
|
|
198871
|
+
this.nextWorkerId += 1;
|
|
198872
|
+
const id = this.nextWorkerId;
|
|
198873
|
+
logger.info(`PackageLoadPool: spawning worker #${id} (script=${this.workerScript.toString()})`);
|
|
198874
|
+
const worker = new Worker(this.workerScript, {
|
|
198875
|
+
name: `malloy-package-load-worker-${id}`
|
|
198876
|
+
});
|
|
198877
|
+
let readyResolve;
|
|
198878
|
+
let readyReject;
|
|
198879
|
+
let readySettled = false;
|
|
198880
|
+
const ready = new Promise((resolve3, reject) => {
|
|
198881
|
+
readyResolve = () => {
|
|
198882
|
+
if (readySettled)
|
|
198883
|
+
return;
|
|
198884
|
+
readySettled = true;
|
|
198885
|
+
resolve3();
|
|
198886
|
+
};
|
|
198887
|
+
readyReject = (err) => {
|
|
198888
|
+
if (readySettled)
|
|
198889
|
+
return;
|
|
198890
|
+
readySettled = true;
|
|
198891
|
+
reject(err);
|
|
198892
|
+
};
|
|
198893
|
+
});
|
|
198894
|
+
ready.catch(() => {});
|
|
198895
|
+
const spawnTimer = setTimeout(() => {
|
|
198896
|
+
readyReject(new Error(`Package-load worker #${id} failed to become ready within ${WORKER_SPAWN_TIMEOUT_MS}ms`));
|
|
198897
|
+
worker.terminate();
|
|
198898
|
+
}, WORKER_SPAWN_TIMEOUT_MS);
|
|
198899
|
+
const pw = {
|
|
198900
|
+
id,
|
|
198901
|
+
worker,
|
|
198902
|
+
ready,
|
|
198903
|
+
inFlight: new Set,
|
|
198904
|
+
exited: false
|
|
198905
|
+
};
|
|
198906
|
+
worker.on("message", (msg) => {
|
|
198907
|
+
this.handleWorkerMessage(pw, msg, readyResolve, spawnTimer);
|
|
198908
|
+
});
|
|
198909
|
+
worker.on("error", (err) => {
|
|
198910
|
+
logger.error(`PackageLoadPool: worker #${id} errored`, {
|
|
198911
|
+
error: err
|
|
198912
|
+
});
|
|
198913
|
+
clearTimeout(spawnTimer);
|
|
198914
|
+
readyReject(err);
|
|
198915
|
+
});
|
|
198916
|
+
worker.on("exit", (code) => {
|
|
198917
|
+
pw.exited = true;
|
|
198918
|
+
clearTimeout(spawnTimer);
|
|
198919
|
+
readyReject(new Error(`Package-load worker #${id} exited before becoming ready (code=${code})`));
|
|
198920
|
+
logger.warn(`PackageLoadPool: worker #${id} exited (code=${code}, inFlight=${pw.inFlight.size})`);
|
|
198921
|
+
for (const jobId of Array.from(pw.inFlight)) {
|
|
198922
|
+
this.failJob(jobId, new Error(`Package-load worker #${id} exited unexpectedly (code=${code})`));
|
|
198923
|
+
}
|
|
198924
|
+
pw.inFlight.clear();
|
|
198925
|
+
const idx = this.workers.indexOf(pw);
|
|
198926
|
+
if (idx >= 0)
|
|
198927
|
+
this.workers.splice(idx, 1);
|
|
198928
|
+
this.tryDispatch();
|
|
198929
|
+
});
|
|
198930
|
+
return pw;
|
|
198931
|
+
}
|
|
198932
|
+
handleWorkerMessage(pw, msg, markReady, spawnTimer) {
|
|
198933
|
+
switch (msg.type) {
|
|
198934
|
+
case "ready":
|
|
198935
|
+
clearTimeout(spawnTimer);
|
|
198936
|
+
markReady();
|
|
198937
|
+
return;
|
|
198938
|
+
case "load-package-result":
|
|
198939
|
+
this.completeJob(pw, msg);
|
|
198940
|
+
return;
|
|
198941
|
+
case "load-package-error":
|
|
198942
|
+
this.errorJob(pw, msg);
|
|
198943
|
+
return;
|
|
198944
|
+
case "connection-metadata":
|
|
198945
|
+
this.handleConnectionMetadata(pw, msg);
|
|
198946
|
+
return;
|
|
198947
|
+
case "schema-for-tables":
|
|
198948
|
+
this.handleSchemaForTables(pw, msg);
|
|
198949
|
+
return;
|
|
198950
|
+
case "schema-for-sql":
|
|
198951
|
+
this.handleSchemaForSql(pw, msg);
|
|
198952
|
+
return;
|
|
198953
|
+
case "read-url":
|
|
198954
|
+
this.handleReadUrl(pw, msg);
|
|
198955
|
+
return;
|
|
198956
|
+
default: {
|
|
198957
|
+
const exhaustive = msg;
|
|
198958
|
+
return;
|
|
198959
|
+
}
|
|
198960
|
+
}
|
|
198961
|
+
}
|
|
198962
|
+
completeJob(pw, msg) {
|
|
198963
|
+
const ctx = this.jobs.get(msg.requestId);
|
|
198964
|
+
if (!ctx)
|
|
198965
|
+
return;
|
|
198966
|
+
this.jobs.delete(msg.requestId);
|
|
198967
|
+
pw.inFlight.delete(msg.requestId);
|
|
198968
|
+
ctx.resolve(msg);
|
|
198969
|
+
this.tryDispatch();
|
|
198970
|
+
}
|
|
198971
|
+
errorJob(pw, msg) {
|
|
198972
|
+
const ctx = this.jobs.get(msg.requestId);
|
|
198973
|
+
if (!ctx)
|
|
198974
|
+
return;
|
|
198975
|
+
this.jobs.delete(msg.requestId);
|
|
198976
|
+
pw.inFlight.delete(msg.requestId);
|
|
198977
|
+
ctx.reject(deserializeError(msg.error));
|
|
198978
|
+
this.tryDispatch();
|
|
198979
|
+
}
|
|
198980
|
+
failJob(jobId, error) {
|
|
198981
|
+
const ctx = this.jobs.get(jobId);
|
|
198982
|
+
if (!ctx)
|
|
198983
|
+
return;
|
|
198984
|
+
this.jobs.delete(jobId);
|
|
198985
|
+
ctx.pw.inFlight.delete(jobId);
|
|
198986
|
+
ctx.reject(error);
|
|
198987
|
+
}
|
|
198988
|
+
async handleConnectionMetadata(pw, msg) {
|
|
198989
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
198990
|
+
const reply = (response) => {
|
|
198991
|
+
pw.worker.postMessage(response);
|
|
198992
|
+
};
|
|
198993
|
+
if (!ctx) {
|
|
198994
|
+
reply({
|
|
198995
|
+
type: "rpc-error",
|
|
198996
|
+
requestId: msg.requestId,
|
|
198997
|
+
ok: false,
|
|
198998
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
198999
|
+
});
|
|
199000
|
+
return;
|
|
199001
|
+
}
|
|
199002
|
+
try {
|
|
199003
|
+
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199004
|
+
reply({
|
|
199005
|
+
type: "connection-metadata-response",
|
|
199006
|
+
requestId: msg.requestId,
|
|
199007
|
+
ok: true,
|
|
199008
|
+
metadata: {
|
|
199009
|
+
name: msg.connectionName,
|
|
199010
|
+
dialectName: conn.dialectName,
|
|
199011
|
+
digest: typeof conn.getDigest === "function" ? conn.getDigest() : msg.connectionName
|
|
199012
|
+
}
|
|
199013
|
+
});
|
|
199014
|
+
} catch (error) {
|
|
199015
|
+
reply({
|
|
199016
|
+
type: "rpc-error",
|
|
199017
|
+
requestId: msg.requestId,
|
|
199018
|
+
ok: false,
|
|
199019
|
+
error: serializeError(error)
|
|
199020
|
+
});
|
|
199021
|
+
}
|
|
199022
|
+
}
|
|
199023
|
+
async handleSchemaForTables(pw, msg) {
|
|
199024
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199025
|
+
const reply = (response) => {
|
|
199026
|
+
pw.worker.postMessage(response);
|
|
199027
|
+
};
|
|
199028
|
+
if (!ctx) {
|
|
199029
|
+
reply({
|
|
199030
|
+
type: "rpc-error",
|
|
199031
|
+
requestId: msg.requestId,
|
|
199032
|
+
ok: false,
|
|
199033
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199034
|
+
});
|
|
199035
|
+
return;
|
|
199036
|
+
}
|
|
199037
|
+
try {
|
|
199038
|
+
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199039
|
+
const result = await conn.fetchSchemaForTables(msg.tables, buildFetchOptions(msg.options));
|
|
199040
|
+
reply({
|
|
199041
|
+
type: "schema-for-tables-response",
|
|
199042
|
+
requestId: msg.requestId,
|
|
199043
|
+
ok: true,
|
|
199044
|
+
schemas: result.schemas,
|
|
199045
|
+
errors: result.errors
|
|
199046
|
+
});
|
|
199047
|
+
} catch (error) {
|
|
199048
|
+
reply({
|
|
199049
|
+
type: "rpc-error",
|
|
199050
|
+
requestId: msg.requestId,
|
|
199051
|
+
ok: false,
|
|
199052
|
+
error: serializeError(error)
|
|
199053
|
+
});
|
|
199054
|
+
}
|
|
199055
|
+
}
|
|
199056
|
+
async handleSchemaForSql(pw, msg) {
|
|
199057
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199058
|
+
const reply = (response) => {
|
|
199059
|
+
pw.worker.postMessage(response);
|
|
199060
|
+
};
|
|
199061
|
+
if (!ctx) {
|
|
199062
|
+
reply({
|
|
199063
|
+
type: "rpc-error",
|
|
199064
|
+
requestId: msg.requestId,
|
|
199065
|
+
ok: false,
|
|
199066
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199067
|
+
});
|
|
199068
|
+
return;
|
|
199069
|
+
}
|
|
199070
|
+
try {
|
|
199071
|
+
const conn = await ctx.connections.lookupConnection(msg.connectionName);
|
|
199072
|
+
const result = await conn.fetchSchemaForSQLStruct(msg.sentence, buildFetchOptions(msg.options));
|
|
199073
|
+
if (result.error !== undefined) {
|
|
199074
|
+
reply({
|
|
199075
|
+
type: "schema-for-sql-response",
|
|
199076
|
+
requestId: msg.requestId,
|
|
199077
|
+
ok: true,
|
|
199078
|
+
error: result.error
|
|
199079
|
+
});
|
|
199080
|
+
} else {
|
|
199081
|
+
reply({
|
|
199082
|
+
type: "schema-for-sql-response",
|
|
199083
|
+
requestId: msg.requestId,
|
|
199084
|
+
ok: true,
|
|
199085
|
+
structDef: result.structDef
|
|
199086
|
+
});
|
|
199087
|
+
}
|
|
199088
|
+
} catch (error) {
|
|
199089
|
+
reply({
|
|
199090
|
+
type: "rpc-error",
|
|
199091
|
+
requestId: msg.requestId,
|
|
199092
|
+
ok: false,
|
|
199093
|
+
error: serializeError(error)
|
|
199094
|
+
});
|
|
199095
|
+
}
|
|
199096
|
+
}
|
|
199097
|
+
async handleReadUrl(pw, msg) {
|
|
199098
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
199099
|
+
const reply = (response) => {
|
|
199100
|
+
pw.worker.postMessage(response);
|
|
199101
|
+
};
|
|
199102
|
+
if (!ctx) {
|
|
199103
|
+
reply({
|
|
199104
|
+
type: "rpc-error",
|
|
199105
|
+
requestId: msg.requestId,
|
|
199106
|
+
ok: false,
|
|
199107
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
199108
|
+
});
|
|
199109
|
+
return;
|
|
199110
|
+
}
|
|
199111
|
+
try {
|
|
199112
|
+
const raw = await ctx.urlReader.readURL(new URL(msg.url));
|
|
199113
|
+
const contents = typeof raw === "string" ? raw : raw.contents;
|
|
199114
|
+
reply({
|
|
199115
|
+
type: "read-url-response",
|
|
199116
|
+
requestId: msg.requestId,
|
|
199117
|
+
ok: true,
|
|
199118
|
+
contents
|
|
199119
|
+
});
|
|
199120
|
+
} catch (error) {
|
|
199121
|
+
reply({
|
|
199122
|
+
type: "rpc-error",
|
|
199123
|
+
requestId: msg.requestId,
|
|
199124
|
+
ok: false,
|
|
199125
|
+
error: serializeError(error)
|
|
199126
|
+
});
|
|
199127
|
+
}
|
|
199128
|
+
}
|
|
199129
|
+
}
|
|
199130
|
+
function buildFetchOptions(options) {
|
|
199131
|
+
const out = {};
|
|
199132
|
+
if (options.refreshTimestamp !== undefined) {
|
|
199133
|
+
out.refreshTimestamp = options.refreshTimestamp;
|
|
199134
|
+
}
|
|
199135
|
+
if (options.modelAnnotation !== undefined) {
|
|
199136
|
+
out.modelAnnotation = options.modelAnnotation;
|
|
199137
|
+
}
|
|
199138
|
+
return out;
|
|
199139
|
+
}
|
|
199140
|
+
function adaptResult(result) {
|
|
199141
|
+
return {
|
|
199142
|
+
packageMetadata: result.packageMetadata,
|
|
199143
|
+
models: result.models.map((m) => ({
|
|
199144
|
+
...m,
|
|
199145
|
+
modelDef: m.modelDef,
|
|
199146
|
+
sourceInfos: m.sourceInfos
|
|
199147
|
+
})),
|
|
199148
|
+
loadDurationMs: result.loadDurationMs
|
|
199149
|
+
};
|
|
199150
|
+
}
|
|
199151
|
+
function serializeError(error) {
|
|
199152
|
+
if (error instanceof Error) {
|
|
199153
|
+
return {
|
|
199154
|
+
name: error.name,
|
|
199155
|
+
message: error.message,
|
|
199156
|
+
stack: error.stack
|
|
199157
|
+
};
|
|
199158
|
+
}
|
|
199159
|
+
return { name: "Error", message: String(error) };
|
|
199160
|
+
}
|
|
199161
|
+
function deserializeError(serialized) {
|
|
199162
|
+
const err = new Error(serialized.message);
|
|
199163
|
+
err.name = serialized.name;
|
|
199164
|
+
if (serialized.stack)
|
|
199165
|
+
err.stack = serialized.stack;
|
|
199166
|
+
if (serialized.malloyProblems) {
|
|
199167
|
+
err.problems = serialized.malloyProblems;
|
|
199168
|
+
}
|
|
199169
|
+
if (serialized.isCompilationError) {
|
|
199170
|
+
const wrapped = new ModelCompilationError(err);
|
|
199171
|
+
if (serialized.stack)
|
|
199172
|
+
wrapped.stack = serialized.stack;
|
|
199173
|
+
return wrapped;
|
|
199174
|
+
}
|
|
199175
|
+
return err;
|
|
199176
|
+
}
|
|
199177
|
+
function getPackageLoadPool() {
|
|
199178
|
+
if (singleton === null) {
|
|
199179
|
+
const n = getPackageLoadWorkerCount();
|
|
199180
|
+
singleton = new PackageLoadPool(n);
|
|
199181
|
+
logger.info(`Malloy package-load worker pool enabled (size=${n}). Override with PACKAGE_LOAD_WORKERS=N (N >= 1).`);
|
|
199182
|
+
}
|
|
199183
|
+
return singleton;
|
|
199184
|
+
}
|
|
199185
|
+
async function __setPackageLoadPoolForTests(pool) {
|
|
199186
|
+
if (singleton && singleton !== pool) {
|
|
199187
|
+
await singleton.shutdown();
|
|
199188
|
+
}
|
|
199189
|
+
singleton = pool;
|
|
199190
|
+
}
|
|
199191
|
+
var PACKAGE_LOAD_JOB_TIMEOUT_MS, WORKER_SPAWN_TIMEOUT_MS = 30000, defaultUrlReader, singleton = null;
|
|
199192
|
+
var init_package_load_pool = __esm(() => {
|
|
199193
|
+
init_errors();
|
|
199194
|
+
init_logger();
|
|
199195
|
+
PACKAGE_LOAD_JOB_TIMEOUT_MS = (() => {
|
|
199196
|
+
const raw = process.env.PACKAGE_LOAD_JOB_TIMEOUT_MS;
|
|
199197
|
+
if (raw === undefined)
|
|
199198
|
+
return 120000;
|
|
199199
|
+
const parsed = Number.parseInt(raw, 10);
|
|
199200
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
199201
|
+
return 120000;
|
|
199202
|
+
return parsed;
|
|
199203
|
+
})();
|
|
199204
|
+
defaultUrlReader = {
|
|
199205
|
+
readURL: async (url2) => {
|
|
199206
|
+
const { promises: fs3 } = await import("fs");
|
|
199207
|
+
const { fileURLToPath: fileURLToPath3 } = await import("url");
|
|
199208
|
+
const filePath = url2.protocol === "file:" ? fileURLToPath3(url2) : url2.toString();
|
|
199209
|
+
return fs3.readFile(filePath, "utf8");
|
|
199210
|
+
}
|
|
199211
|
+
};
|
|
199212
|
+
});
|
|
199213
|
+
|
|
198504
199214
|
// ../../node_modules/concat-map/index.js
|
|
198505
199215
|
var require_concat_map = __commonJS((exports, module) => {
|
|
198506
199216
|
module.exports = function(xs, fn) {
|
|
@@ -208467,7 +209177,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
208467
209177
|
return path12;
|
|
208468
209178
|
}
|
|
208469
209179
|
exports.normalize = normalize2;
|
|
208470
|
-
function
|
|
209180
|
+
function join9(aRoot, aPath) {
|
|
208471
209181
|
if (aRoot === "") {
|
|
208472
209182
|
aRoot = ".";
|
|
208473
209183
|
}
|
|
@@ -208499,7 +209209,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
208499
209209
|
}
|
|
208500
209210
|
return joined;
|
|
208501
209211
|
}
|
|
208502
|
-
exports.join =
|
|
209212
|
+
exports.join = join9;
|
|
208503
209213
|
exports.isAbsolute = function(aPath) {
|
|
208504
209214
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
208505
209215
|
};
|
|
@@ -208672,7 +209382,7 @@ var require_util13 = __commonJS((exports) => {
|
|
|
208672
209382
|
parsed.path = parsed.path.substring(0, index + 1);
|
|
208673
209383
|
}
|
|
208674
209384
|
}
|
|
208675
|
-
sourceURL =
|
|
209385
|
+
sourceURL = join9(urlGenerate(parsed), sourceURL);
|
|
208676
209386
|
}
|
|
208677
209387
|
return normalize2(sourceURL);
|
|
208678
209388
|
}
|
|
@@ -211070,6 +211780,7 @@ var require_lib8 = __commonJS((exports, module) => {
|
|
|
211070
211780
|
});
|
|
211071
211781
|
|
|
211072
211782
|
// src/instrumentation.ts
|
|
211783
|
+
init_logger();
|
|
211073
211784
|
var import_api = __toESM(require_src(), 1);
|
|
211074
211785
|
var import_auto_instrumentations_node = __toESM(require_src59(), 1);
|
|
211075
211786
|
var import_exporter_logs_otlp_proto = __toESM(require_src66(), 1);
|
|
@@ -211082,93 +211793,6 @@ var import_sdk_node = __toESM(require_src106(), 1);
|
|
|
211082
211793
|
var import_sdk_trace_base = __toESM(require_src82(), 1);
|
|
211083
211794
|
var import_semantic_conventions = __toESM(require_src2(), 1);
|
|
211084
211795
|
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
211085
|
-
|
|
211086
|
-
// src/logger.ts
|
|
211087
|
-
var import_winston = __toESM(require_winston(), 1);
|
|
211088
|
-
var isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
|
|
211089
|
-
var VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
|
|
211090
|
-
var getLogLevel = () => {
|
|
211091
|
-
if (process.env.LOG_LEVEL) {
|
|
211092
|
-
const logLevel = process.env.LOG_LEVEL.toLowerCase();
|
|
211093
|
-
if (VALID_LOG_LEVELS.includes(logLevel)) {
|
|
211094
|
-
return logLevel;
|
|
211095
|
-
} else {
|
|
211096
|
-
console.error(`Invalid log level: ${process.env.LOG_LEVEL}. Valid log levels are: ${VALID_LOG_LEVELS.join(", ")}. Defaulting to "debug".`);
|
|
211097
|
-
}
|
|
211098
|
-
}
|
|
211099
|
-
return "debug";
|
|
211100
|
-
};
|
|
211101
|
-
var logger = import_winston.default.createLogger({
|
|
211102
|
-
level: getLogLevel(),
|
|
211103
|
-
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()),
|
|
211104
|
-
transports: [new import_winston.default.transports.Console]
|
|
211105
|
-
});
|
|
211106
|
-
function extractTraceIdFromTraceparent(traceparent) {
|
|
211107
|
-
if (!traceparent) {
|
|
211108
|
-
return;
|
|
211109
|
-
}
|
|
211110
|
-
const parts = traceparent.split("-");
|
|
211111
|
-
const traceId = parts.length >= 2 ? parts[1] : parts.length == 1 ? parts[0] : undefined;
|
|
211112
|
-
if (traceId && traceId.length === 32 && /^[0-9a-fA-F]{32}$/.test(traceId)) {
|
|
211113
|
-
return traceId;
|
|
211114
|
-
}
|
|
211115
|
-
return;
|
|
211116
|
-
}
|
|
211117
|
-
var DISABLE_RESPONSE_LOGGING = process.env.DISABLE_RESPONSE_LOGGING === "true" || process.env.DISABLE_RESPONSE_LOGGING === "1";
|
|
211118
|
-
function formatDuration(durationMs) {
|
|
211119
|
-
if (durationMs >= 1000) {
|
|
211120
|
-
const seconds = durationMs / 1000;
|
|
211121
|
-
return `${seconds.toFixed(2)}s`;
|
|
211122
|
-
}
|
|
211123
|
-
return `${durationMs.toFixed(2)}ms`;
|
|
211124
|
-
}
|
|
211125
|
-
var loggerMiddleware = (req, res, next) => {
|
|
211126
|
-
const startTime = performance.now();
|
|
211127
|
-
const resJson = res.json;
|
|
211128
|
-
res.json = (body) => {
|
|
211129
|
-
res.locals.body = body;
|
|
211130
|
-
return resJson.call(res, body);
|
|
211131
|
-
};
|
|
211132
|
-
res.on("finish", () => {
|
|
211133
|
-
const endTime = performance.now();
|
|
211134
|
-
const durationMs = endTime - startTime;
|
|
211135
|
-
const traceparent = req.headers["traceparent"];
|
|
211136
|
-
const traceId = extractTraceIdFromTraceparent(traceparent);
|
|
211137
|
-
const logMetadata = {
|
|
211138
|
-
statusCode: res.statusCode,
|
|
211139
|
-
duration: formatDuration(durationMs),
|
|
211140
|
-
payload: req.body,
|
|
211141
|
-
params: req.params,
|
|
211142
|
-
query: req.query
|
|
211143
|
-
};
|
|
211144
|
-
if (!DISABLE_RESPONSE_LOGGING) {
|
|
211145
|
-
logMetadata.response = res.locals.body;
|
|
211146
|
-
}
|
|
211147
|
-
if (traceId) {
|
|
211148
|
-
logMetadata.traceId = traceId;
|
|
211149
|
-
}
|
|
211150
|
-
if (req.url !== "/metrics" && req.url !== "/health" && req.url !== "/health/liveness" && req.url !== "/health/readiness") {
|
|
211151
|
-
logger.info(`${req.method} ${req.url}`, logMetadata);
|
|
211152
|
-
}
|
|
211153
|
-
});
|
|
211154
|
-
next();
|
|
211155
|
-
};
|
|
211156
|
-
var logAxiosError = (error) => {
|
|
211157
|
-
if (error.response) {
|
|
211158
|
-
logger.error("Axios server-side error", {
|
|
211159
|
-
url: error.response.config.url,
|
|
211160
|
-
status: error.response.status,
|
|
211161
|
-
headers: error.response.headers,
|
|
211162
|
-
data: error.response.data
|
|
211163
|
-
});
|
|
211164
|
-
} else if (error.request) {
|
|
211165
|
-
logger.error("Axios client-side error", { error: error.request });
|
|
211166
|
-
} else {
|
|
211167
|
-
logger.error("Axios unknown error", { error });
|
|
211168
|
-
}
|
|
211169
|
-
};
|
|
211170
|
-
|
|
211171
|
-
// src/instrumentation.ts
|
|
211172
211796
|
var prometheusExporter = null;
|
|
211173
211797
|
var sdk = null;
|
|
211174
211798
|
function getPrometheusMetricsHandler() {
|
|
@@ -216311,7 +216935,7 @@ var import_express = __toESM(require_express(), 1);
|
|
|
216311
216935
|
var import_http_proxy_middleware = __toESM(require_dist4(), 1);
|
|
216312
216936
|
import * as http2 from "http";
|
|
216313
216937
|
import * as path12 from "path";
|
|
216314
|
-
import { fileURLToPath as
|
|
216938
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
216315
216939
|
|
|
216316
216940
|
// src/controller/compile.controller.ts
|
|
216317
216941
|
class CompileController {
|
|
@@ -216331,148 +216955,9 @@ class CompileController {
|
|
|
216331
216955
|
}
|
|
216332
216956
|
}
|
|
216333
216957
|
|
|
216334
|
-
// src/
|
|
216335
|
-
|
|
216336
|
-
|
|
216337
|
-
// src/constants.ts
|
|
216338
|
-
import os from "os";
|
|
216339
|
-
var API_PREFIX = "/api/v0";
|
|
216340
|
-
var README_NAME = "README.md";
|
|
216341
|
-
var PUBLISHER_CONFIG_NAME = "publisher.config.json";
|
|
216342
|
-
var PACKAGE_MANIFEST_NAME = "publisher.json";
|
|
216343
|
-
var MODEL_FILE_SUFFIX = ".malloy";
|
|
216344
|
-
var NOTEBOOK_FILE_SUFFIX = ".malloynb";
|
|
216345
|
-
var ROW_LIMIT = 1000;
|
|
216346
|
-
var TEMP_DIR_PATH = os.tmpdir();
|
|
216347
|
-
var PUBLISHER_DATA_DIR = "publisher_data";
|
|
216348
|
-
|
|
216349
|
-
// src/errors.ts
|
|
216350
|
-
function internalErrorToHttpError(error) {
|
|
216351
|
-
if (error instanceof BadRequestError) {
|
|
216352
|
-
return httpError(400, error.message);
|
|
216353
|
-
} else if (error instanceof FrozenConfigError) {
|
|
216354
|
-
return httpError(403, error.message);
|
|
216355
|
-
} else if (error instanceof EnvironmentNotFoundError) {
|
|
216356
|
-
return httpError(404, error.message);
|
|
216357
|
-
} else if (error instanceof PackageNotFoundError) {
|
|
216358
|
-
return httpError(404, error.message);
|
|
216359
|
-
} else if (error instanceof ModelNotFoundError) {
|
|
216360
|
-
return httpError(404, error.message);
|
|
216361
|
-
} else if (error instanceof MalloyError) {
|
|
216362
|
-
return httpError(400, error.message);
|
|
216363
|
-
} else if (error instanceof ConnectionNotFoundError) {
|
|
216364
|
-
return httpError(404, error.message);
|
|
216365
|
-
} else if (error instanceof ConnectionAuthError) {
|
|
216366
|
-
return httpError(422, error.message);
|
|
216367
|
-
} else if (error instanceof ModelCompilationError) {
|
|
216368
|
-
return httpError(424, error.message);
|
|
216369
|
-
} else if (error instanceof ConnectionError) {
|
|
216370
|
-
return httpError(502, error.message);
|
|
216371
|
-
} else if (error instanceof MaterializationNotFoundError) {
|
|
216372
|
-
return httpError(404, error.message);
|
|
216373
|
-
} else if (error instanceof MaterializationConflictError) {
|
|
216374
|
-
return httpError(409, error.message);
|
|
216375
|
-
} else if (error instanceof InvalidStateTransitionError) {
|
|
216376
|
-
return httpError(409, error.message);
|
|
216377
|
-
} else if (error instanceof ServiceUnavailableError) {
|
|
216378
|
-
return httpError(503, error.message);
|
|
216379
|
-
} else {
|
|
216380
|
-
return httpError(500, error.message);
|
|
216381
|
-
}
|
|
216382
|
-
}
|
|
216383
|
-
function httpError(code, message) {
|
|
216384
|
-
return {
|
|
216385
|
-
status: code,
|
|
216386
|
-
json: {
|
|
216387
|
-
code,
|
|
216388
|
-
message
|
|
216389
|
-
}
|
|
216390
|
-
};
|
|
216391
|
-
}
|
|
216392
|
-
|
|
216393
|
-
class NotImplementedError extends Error {
|
|
216394
|
-
constructor(message) {
|
|
216395
|
-
super(message);
|
|
216396
|
-
}
|
|
216397
|
-
}
|
|
216398
|
-
|
|
216399
|
-
class BadRequestError extends Error {
|
|
216400
|
-
constructor(message) {
|
|
216401
|
-
super(message);
|
|
216402
|
-
}
|
|
216403
|
-
}
|
|
216404
|
-
|
|
216405
|
-
class EnvironmentNotFoundError extends Error {
|
|
216406
|
-
constructor(message) {
|
|
216407
|
-
super(message);
|
|
216408
|
-
}
|
|
216409
|
-
}
|
|
216410
|
-
|
|
216411
|
-
class PackageNotFoundError extends Error {
|
|
216412
|
-
constructor(message) {
|
|
216413
|
-
super(message);
|
|
216414
|
-
}
|
|
216415
|
-
}
|
|
216416
|
-
|
|
216417
|
-
class ModelNotFoundError extends Error {
|
|
216418
|
-
constructor(message) {
|
|
216419
|
-
super(message);
|
|
216420
|
-
}
|
|
216421
|
-
}
|
|
216422
|
-
|
|
216423
|
-
class ConnectionNotFoundError extends Error {
|
|
216424
|
-
constructor(message) {
|
|
216425
|
-
super(message);
|
|
216426
|
-
}
|
|
216427
|
-
}
|
|
216428
|
-
|
|
216429
|
-
class ConnectionError extends Error {
|
|
216430
|
-
constructor(message) {
|
|
216431
|
-
super(message);
|
|
216432
|
-
}
|
|
216433
|
-
}
|
|
216434
|
-
|
|
216435
|
-
class ConnectionAuthError extends Error {
|
|
216436
|
-
constructor(message) {
|
|
216437
|
-
super(message);
|
|
216438
|
-
}
|
|
216439
|
-
}
|
|
216440
|
-
|
|
216441
|
-
class ModelCompilationError extends Error {
|
|
216442
|
-
constructor(error) {
|
|
216443
|
-
super(error.message);
|
|
216444
|
-
}
|
|
216445
|
-
}
|
|
216446
|
-
|
|
216447
|
-
class FrozenConfigError extends Error {
|
|
216448
|
-
constructor(message = `Publisher config can't be updated when ${PUBLISHER_CONFIG_NAME} has { "frozenConfig": true }`) {
|
|
216449
|
-
super(message);
|
|
216450
|
-
}
|
|
216451
|
-
}
|
|
216452
|
-
|
|
216453
|
-
class MaterializationNotFoundError extends Error {
|
|
216454
|
-
constructor(message) {
|
|
216455
|
-
super(message);
|
|
216456
|
-
}
|
|
216457
|
-
}
|
|
216458
|
-
|
|
216459
|
-
class MaterializationConflictError extends Error {
|
|
216460
|
-
constructor(message) {
|
|
216461
|
-
super(message);
|
|
216462
|
-
}
|
|
216463
|
-
}
|
|
216464
|
-
|
|
216465
|
-
class InvalidStateTransitionError extends Error {
|
|
216466
|
-
constructor(message) {
|
|
216467
|
-
super(message);
|
|
216468
|
-
}
|
|
216469
|
-
}
|
|
216470
|
-
|
|
216471
|
-
class ServiceUnavailableError extends Error {
|
|
216472
|
-
constructor(message) {
|
|
216473
|
-
super(message);
|
|
216474
|
-
}
|
|
216475
|
-
}
|
|
216958
|
+
// src/controller/connection.controller.ts
|
|
216959
|
+
init_errors();
|
|
216960
|
+
init_logger();
|
|
216476
216961
|
|
|
216477
216962
|
// src/service/connection.ts
|
|
216478
216963
|
import"@malloydata/db-bigquery";
|
|
@@ -219757,10 +220242,12 @@ var {
|
|
|
219757
220242
|
} = axios_default;
|
|
219758
220243
|
|
|
219759
220244
|
// src/service/connection.ts
|
|
220245
|
+
init_logger();
|
|
219760
220246
|
import fs from "fs/promises";
|
|
219761
220247
|
import path2 from "path";
|
|
219762
220248
|
|
|
219763
220249
|
// src/pg_helpers.ts
|
|
220250
|
+
init_errors();
|
|
219764
220251
|
function pgConnectTimeoutSeconds() {
|
|
219765
220252
|
const raw = process.env.PG_CONNECT_TIMEOUT_SECONDS;
|
|
219766
220253
|
if (!raw)
|
|
@@ -221011,6 +221498,8 @@ async function testConnectionConfig(connectionConfig) {
|
|
|
221011
221498
|
}
|
|
221012
221499
|
|
|
221013
221500
|
// src/service/connection_service.ts
|
|
221501
|
+
init_errors();
|
|
221502
|
+
init_logger();
|
|
221014
221503
|
async function runEnvironmentConnectionUpdate(environment, fn) {
|
|
221015
221504
|
if (environment.runConnectionUpdateExclusive) {
|
|
221016
221505
|
return environment.runConnectionUpdateExclusive(fn);
|
|
@@ -221122,11 +221611,13 @@ class ConnectionService {
|
|
|
221122
221611
|
}
|
|
221123
221612
|
|
|
221124
221613
|
// src/service/db_utils.ts
|
|
221614
|
+
init_logger();
|
|
221125
221615
|
var import_bigquery = __toESM(require_src121(), 1);
|
|
221126
221616
|
import { ClientSecretCredential } from "@azure/identity";
|
|
221127
221617
|
import { ContainerClient } from "@azure/storage-blob";
|
|
221128
221618
|
|
|
221129
221619
|
// src/service/gcs_s3_utils.ts
|
|
221620
|
+
init_logger();
|
|
221130
221621
|
var import_client_s3 = __toESM(require_dist_cjs75(), 1);
|
|
221131
221622
|
function gcsConnectionToCredentials(gcsConnection) {
|
|
221132
221623
|
return {
|
|
@@ -222474,6 +222965,8 @@ class DatabaseController {
|
|
|
222474
222965
|
}
|
|
222475
222966
|
|
|
222476
222967
|
// src/controller/model.controller.ts
|
|
222968
|
+
init_errors();
|
|
222969
|
+
|
|
222477
222970
|
class ModelController {
|
|
222478
222971
|
environmentStore;
|
|
222479
222972
|
constructor(environmentStore) {
|
|
@@ -222535,6 +223028,9 @@ class ModelController {
|
|
|
222535
223028
|
}
|
|
222536
223029
|
|
|
222537
223030
|
// src/controller/package.controller.ts
|
|
223031
|
+
init_errors();
|
|
223032
|
+
init_logger();
|
|
223033
|
+
|
|
222538
223034
|
class PackageController {
|
|
222539
223035
|
environmentStore;
|
|
222540
223036
|
manifestService;
|
|
@@ -222647,6 +223143,8 @@ class PackageController {
|
|
|
222647
223143
|
}
|
|
222648
223144
|
|
|
222649
223145
|
// src/controller/query.controller.ts
|
|
223146
|
+
init_constants();
|
|
223147
|
+
init_errors();
|
|
222650
223148
|
var import_render_validator = __toESM(require_dist10(), 1);
|
|
222651
223149
|
function bigIntReplacer(_key, value) {
|
|
222652
223150
|
if (typeof value === "bigint") {
|
|
@@ -224250,6 +224748,7 @@ function watch(paths, options = {}) {
|
|
|
224250
224748
|
var esm_default = { watch, FSWatcher };
|
|
224251
224749
|
|
|
224252
224750
|
// src/controller/watch-mode.controller.ts
|
|
224751
|
+
init_logger();
|
|
224253
224752
|
import path11 from "path";
|
|
224254
224753
|
|
|
224255
224754
|
// src/service/environment_store.ts
|
|
@@ -224482,7 +224981,7 @@ var __defProp2 = Object.defineProperty;
|
|
|
224482
224981
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
224483
224982
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
224484
224983
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
224485
|
-
var
|
|
224984
|
+
var __esm2 = (fn, res) => function __init() {
|
|
224486
224985
|
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
224487
224986
|
};
|
|
224488
224987
|
var __commonJS2 = (cb, mod2) => function __require2() {
|
|
@@ -224513,13 +225012,13 @@ function toPaths(pathSpec) {
|
|
|
224513
225012
|
return cache.get(pathSpec) || [];
|
|
224514
225013
|
}
|
|
224515
225014
|
var cache;
|
|
224516
|
-
var init_pathspec =
|
|
225015
|
+
var init_pathspec = __esm2({
|
|
224517
225016
|
"src/lib/args/pathspec.ts"() {
|
|
224518
225017
|
cache = /* @__PURE__ */ new WeakMap;
|
|
224519
225018
|
}
|
|
224520
225019
|
});
|
|
224521
225020
|
var GitError;
|
|
224522
|
-
var init_git_error =
|
|
225021
|
+
var init_git_error = __esm2({
|
|
224523
225022
|
"src/lib/errors/git-error.ts"() {
|
|
224524
225023
|
GitError = class extends Error {
|
|
224525
225024
|
constructor(task, message) {
|
|
@@ -224531,7 +225030,7 @@ var init_git_error = __esm({
|
|
|
224531
225030
|
}
|
|
224532
225031
|
});
|
|
224533
225032
|
var GitResponseError;
|
|
224534
|
-
var init_git_response_error =
|
|
225033
|
+
var init_git_response_error = __esm2({
|
|
224535
225034
|
"src/lib/errors/git-response-error.ts"() {
|
|
224536
225035
|
init_git_error();
|
|
224537
225036
|
GitResponseError = class extends GitError {
|
|
@@ -224543,7 +225042,7 @@ var init_git_response_error = __esm({
|
|
|
224543
225042
|
}
|
|
224544
225043
|
});
|
|
224545
225044
|
var TaskConfigurationError;
|
|
224546
|
-
var init_task_configuration_error =
|
|
225045
|
+
var init_task_configuration_error = __esm2({
|
|
224547
225046
|
"src/lib/errors/task-configuration-error.ts"() {
|
|
224548
225047
|
init_git_error();
|
|
224549
225048
|
TaskConfigurationError = class extends GitError {
|
|
@@ -224666,7 +225165,7 @@ function orVoid(input) {
|
|
|
224666
225165
|
var NULL;
|
|
224667
225166
|
var NOOP;
|
|
224668
225167
|
var objectToString;
|
|
224669
|
-
var init_util =
|
|
225168
|
+
var init_util = __esm2({
|
|
224670
225169
|
"src/lib/utils/util.ts"() {
|
|
224671
225170
|
NULL = "\x00";
|
|
224672
225171
|
NOOP = () => {};
|
|
@@ -224694,7 +225193,7 @@ var filterString;
|
|
|
224694
225193
|
var filterStringArray;
|
|
224695
225194
|
var filterStringOrStringArray;
|
|
224696
225195
|
var filterHasLength;
|
|
224697
|
-
var init_argument_filters =
|
|
225196
|
+
var init_argument_filters = __esm2({
|
|
224698
225197
|
"src/lib/utils/argument-filters.ts"() {
|
|
224699
225198
|
init_util();
|
|
224700
225199
|
init_pathspec();
|
|
@@ -224719,7 +225218,7 @@ var init_argument_filters = __esm({
|
|
|
224719
225218
|
}
|
|
224720
225219
|
});
|
|
224721
225220
|
var ExitCodes;
|
|
224722
|
-
var init_exit_codes =
|
|
225221
|
+
var init_exit_codes = __esm2({
|
|
224723
225222
|
"src/lib/utils/exit-codes.ts"() {
|
|
224724
225223
|
ExitCodes = /* @__PURE__ */ ((ExitCodes2) => {
|
|
224725
225224
|
ExitCodes2[ExitCodes2["SUCCESS"] = 0] = "SUCCESS";
|
|
@@ -224731,7 +225230,7 @@ var init_exit_codes = __esm({
|
|
|
224731
225230
|
}
|
|
224732
225231
|
});
|
|
224733
225232
|
var GitOutputStreams;
|
|
224734
|
-
var init_git_output_streams =
|
|
225233
|
+
var init_git_output_streams = __esm2({
|
|
224735
225234
|
"src/lib/utils/git-output-streams.ts"() {
|
|
224736
225235
|
GitOutputStreams = class _GitOutputStreams {
|
|
224737
225236
|
constructor(stdOut, stdErr) {
|
|
@@ -224746,7 +225245,7 @@ var init_git_output_streams = __esm({
|
|
|
224746
225245
|
});
|
|
224747
225246
|
var LineParser;
|
|
224748
225247
|
var RemoteLineParser;
|
|
224749
|
-
var init_line_parser =
|
|
225248
|
+
var init_line_parser = __esm2({
|
|
224750
225249
|
"src/lib/utils/line-parser.ts"() {
|
|
224751
225250
|
LineParser = class {
|
|
224752
225251
|
constructor(regExp, useMatches) {
|
|
@@ -224803,7 +225302,7 @@ function createInstanceConfig(...options) {
|
|
|
224803
225302
|
return config;
|
|
224804
225303
|
}
|
|
224805
225304
|
var defaultOptions2;
|
|
224806
|
-
var init_simple_git_options =
|
|
225305
|
+
var init_simple_git_options = __esm2({
|
|
224807
225306
|
"src/lib/utils/simple-git-options.ts"() {
|
|
224808
225307
|
defaultOptions2 = {
|
|
224809
225308
|
binary: "git",
|
|
@@ -224860,7 +225359,7 @@ function trailingFunctionArgument(args, includeNoop = true) {
|
|
|
224860
225359
|
const callback = asFunction(last(args));
|
|
224861
225360
|
return includeNoop || isUserFunction(callback) ? callback : undefined;
|
|
224862
225361
|
}
|
|
224863
|
-
var init_task_options =
|
|
225362
|
+
var init_task_options = __esm2({
|
|
224864
225363
|
"src/lib/utils/task-options.ts"() {
|
|
224865
225364
|
init_argument_filters();
|
|
224866
225365
|
init_util();
|
|
@@ -224884,7 +225383,7 @@ function parseStringResponse(result, parsers12, texts, trim2 = true) {
|
|
|
224884
225383
|
});
|
|
224885
225384
|
return result;
|
|
224886
225385
|
}
|
|
224887
|
-
var init_task_parser =
|
|
225386
|
+
var init_task_parser = __esm2({
|
|
224888
225387
|
"src/lib/utils/task-parser.ts"() {
|
|
224889
225388
|
init_util();
|
|
224890
225389
|
}
|
|
@@ -224935,7 +225434,7 @@ __export2(utils_exports, {
|
|
|
224935
225434
|
trailingFunctionArgument: () => trailingFunctionArgument,
|
|
224936
225435
|
trailingOptionsArgument: () => trailingOptionsArgument
|
|
224937
225436
|
});
|
|
224938
|
-
var init_utils =
|
|
225437
|
+
var init_utils = __esm2({
|
|
224939
225438
|
"src/lib/utils/index.ts"() {
|
|
224940
225439
|
init_argument_filters();
|
|
224941
225440
|
init_exit_codes();
|
|
@@ -224995,7 +225494,7 @@ function isNotRepoMessage(error) {
|
|
|
224995
225494
|
var CheckRepoActions;
|
|
224996
225495
|
var onError;
|
|
224997
225496
|
var parser;
|
|
224998
|
-
var init_check_is_repo =
|
|
225497
|
+
var init_check_is_repo = __esm2({
|
|
224999
225498
|
"src/lib/tasks/check-is-repo.ts"() {
|
|
225000
225499
|
init_utils();
|
|
225001
225500
|
CheckRepoActions = /* @__PURE__ */ ((CheckRepoActions2) => {
|
|
@@ -225029,7 +225528,7 @@ var CleanResponse;
|
|
|
225029
225528
|
var removalRegexp;
|
|
225030
225529
|
var dryRunRemovalRegexp;
|
|
225031
225530
|
var isFolderRegexp;
|
|
225032
|
-
var init_CleanSummary =
|
|
225531
|
+
var init_CleanSummary = __esm2({
|
|
225033
225532
|
"src/lib/responses/CleanSummary.ts"() {
|
|
225034
225533
|
init_utils();
|
|
225035
225534
|
CleanResponse = class {
|
|
@@ -225096,7 +225595,7 @@ function isEmptyTask(task) {
|
|
|
225096
225595
|
return task.format === "empty" || !task.commands.length;
|
|
225097
225596
|
}
|
|
225098
225597
|
var EMPTY_COMMANDS;
|
|
225099
|
-
var init_task =
|
|
225598
|
+
var init_task = __esm2({
|
|
225100
225599
|
"src/lib/tasks/task.ts"() {
|
|
225101
225600
|
init_task_configuration_error();
|
|
225102
225601
|
EMPTY_COMMANDS = [];
|
|
@@ -225174,7 +225673,7 @@ var CONFIG_ERROR_MODE_REQUIRED;
|
|
|
225174
225673
|
var CONFIG_ERROR_UNKNOWN_OPTION;
|
|
225175
225674
|
var CleanOptions;
|
|
225176
225675
|
var CleanOptionValues;
|
|
225177
|
-
var init_clean =
|
|
225676
|
+
var init_clean = __esm2({
|
|
225178
225677
|
"src/lib/tasks/clean.ts"() {
|
|
225179
225678
|
init_CleanSummary();
|
|
225180
225679
|
init_utils();
|
|
@@ -225247,7 +225746,7 @@ function* configParser(text, requestedKey = null) {
|
|
|
225247
225746
|
}
|
|
225248
225747
|
}
|
|
225249
225748
|
var ConfigList;
|
|
225250
|
-
var init_ConfigList =
|
|
225749
|
+
var init_ConfigList = __esm2({
|
|
225251
225750
|
"src/lib/responses/ConfigList.ts"() {
|
|
225252
225751
|
init_utils();
|
|
225253
225752
|
ConfigList = class {
|
|
@@ -225345,7 +225844,7 @@ function config_default() {
|
|
|
225345
225844
|
};
|
|
225346
225845
|
}
|
|
225347
225846
|
var GitConfigScope;
|
|
225348
|
-
var init_config =
|
|
225847
|
+
var init_config = __esm2({
|
|
225349
225848
|
"src/lib/tasks/config.ts"() {
|
|
225350
225849
|
init_ConfigList();
|
|
225351
225850
|
init_utils();
|
|
@@ -225363,7 +225862,7 @@ function isDiffNameStatus(input) {
|
|
|
225363
225862
|
}
|
|
225364
225863
|
var DiffNameStatus;
|
|
225365
225864
|
var diffNameStatus;
|
|
225366
|
-
var init_diff_name_status =
|
|
225865
|
+
var init_diff_name_status = __esm2({
|
|
225367
225866
|
"src/lib/tasks/diff-name-status.ts"() {
|
|
225368
225867
|
DiffNameStatus = /* @__PURE__ */ ((DiffNameStatus2) => {
|
|
225369
225868
|
DiffNameStatus2["ADDED"] = "A";
|
|
@@ -225428,7 +225927,7 @@ var disallowedOptions;
|
|
|
225428
225927
|
var Query;
|
|
225429
225928
|
var _a;
|
|
225430
225929
|
var GrepQuery;
|
|
225431
|
-
var init_grep =
|
|
225930
|
+
var init_grep = __esm2({
|
|
225432
225931
|
"src/lib/tasks/grep.ts"() {
|
|
225433
225932
|
init_utils();
|
|
225434
225933
|
init_task();
|
|
@@ -225484,7 +225983,7 @@ function isValidResetMode(mode) {
|
|
|
225484
225983
|
}
|
|
225485
225984
|
var ResetMode;
|
|
225486
225985
|
var ResetModes;
|
|
225487
|
-
var init_reset =
|
|
225986
|
+
var init_reset = __esm2({
|
|
225488
225987
|
"src/lib/tasks/reset.ts"() {
|
|
225489
225988
|
init_task();
|
|
225490
225989
|
ResetMode = /* @__PURE__ */ ((ResetMode2) => {
|
|
@@ -225546,7 +226045,7 @@ function createLogger(label, verbose, initialStep, infoDebugger = createLog()) {
|
|
|
225546
226045
|
});
|
|
225547
226046
|
}
|
|
225548
226047
|
}
|
|
225549
|
-
var init_git_logger =
|
|
226048
|
+
var init_git_logger = __esm2({
|
|
225550
226049
|
"src/lib/git-logger.ts"() {
|
|
225551
226050
|
init_utils();
|
|
225552
226051
|
import_debug.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
|
|
@@ -225559,7 +226058,7 @@ var init_git_logger = __esm({
|
|
|
225559
226058
|
}
|
|
225560
226059
|
});
|
|
225561
226060
|
var TasksPendingQueue;
|
|
225562
|
-
var init_tasks_pending_queue =
|
|
226061
|
+
var init_tasks_pending_queue = __esm2({
|
|
225563
226062
|
"src/lib/runners/tasks-pending-queue.ts"() {
|
|
225564
226063
|
init_git_error();
|
|
225565
226064
|
init_git_logger();
|
|
@@ -225643,7 +226142,7 @@ function onDataReceived(target, name, logger2, output) {
|
|
|
225643
226142
|
};
|
|
225644
226143
|
}
|
|
225645
226144
|
var GitExecutorChain;
|
|
225646
|
-
var init_git_executor_chain =
|
|
226145
|
+
var init_git_executor_chain = __esm2({
|
|
225647
226146
|
"src/lib/runners/git-executor-chain.ts"() {
|
|
225648
226147
|
init_git_error();
|
|
225649
226148
|
init_task();
|
|
@@ -225808,7 +226307,7 @@ __export2(git_executor_exports, {
|
|
|
225808
226307
|
GitExecutor: () => GitExecutor
|
|
225809
226308
|
});
|
|
225810
226309
|
var GitExecutor;
|
|
225811
|
-
var init_git_executor =
|
|
226310
|
+
var init_git_executor = __esm2({
|
|
225812
226311
|
"src/lib/runners/git-executor.ts"() {
|
|
225813
226312
|
init_git_executor_chain();
|
|
225814
226313
|
GitExecutor = class {
|
|
@@ -225859,7 +226358,7 @@ function addDeprecationNoticeToError(err) {
|
|
|
225859
226358
|
return all3;
|
|
225860
226359
|
}
|
|
225861
226360
|
}
|
|
225862
|
-
var init_task_callback =
|
|
226361
|
+
var init_task_callback = __esm2({
|
|
225863
226362
|
"src/lib/task-callback.ts"() {
|
|
225864
226363
|
init_git_response_error();
|
|
225865
226364
|
init_utils();
|
|
@@ -225873,7 +226372,7 @@ function changeWorkingDirectoryTask(directory, root) {
|
|
|
225873
226372
|
return (root || instance).cwd = directory;
|
|
225874
226373
|
});
|
|
225875
226374
|
}
|
|
225876
|
-
var init_change_working_directory =
|
|
226375
|
+
var init_change_working_directory = __esm2({
|
|
225877
226376
|
"src/lib/tasks/change-working-directory.ts"() {
|
|
225878
226377
|
init_utils();
|
|
225879
226378
|
init_task();
|
|
@@ -225899,7 +226398,7 @@ function checkout_default() {
|
|
|
225899
226398
|
}
|
|
225900
226399
|
};
|
|
225901
226400
|
}
|
|
225902
|
-
var init_checkout =
|
|
226401
|
+
var init_checkout = __esm2({
|
|
225903
226402
|
"src/lib/tasks/checkout.ts"() {
|
|
225904
226403
|
init_utils();
|
|
225905
226404
|
init_task();
|
|
@@ -225931,7 +226430,7 @@ function count_objects_default() {
|
|
|
225931
226430
|
};
|
|
225932
226431
|
}
|
|
225933
226432
|
var parser2;
|
|
225934
|
-
var init_count_objects =
|
|
226433
|
+
var init_count_objects = __esm2({
|
|
225935
226434
|
"src/lib/tasks/count-objects.ts"() {
|
|
225936
226435
|
init_utils();
|
|
225937
226436
|
parser2 = new LineParser(/([a-z-]+): (\d+)$/, (result, [key, value]) => {
|
|
@@ -225957,7 +226456,7 @@ function parseCommitResult(stdOut) {
|
|
|
225957
226456
|
return parseStringResponse(result, parsers, stdOut);
|
|
225958
226457
|
}
|
|
225959
226458
|
var parsers;
|
|
225960
|
-
var init_parse_commit =
|
|
226459
|
+
var init_parse_commit = __esm2({
|
|
225961
226460
|
"src/lib/parsers/parse-commit.ts"() {
|
|
225962
226461
|
init_utils();
|
|
225963
226462
|
parsers = [
|
|
@@ -226021,7 +226520,7 @@ function commit_default() {
|
|
|
226021
226520
|
return !filterStringOrStringArray(message) && configurationErrorTask(`git.commit: requires the commit message to be supplied as a string/string[]`);
|
|
226022
226521
|
}
|
|
226023
226522
|
}
|
|
226024
|
-
var init_commit =
|
|
226523
|
+
var init_commit = __esm2({
|
|
226025
226524
|
"src/lib/tasks/commit.ts"() {
|
|
226026
226525
|
init_parse_commit();
|
|
226027
226526
|
init_utils();
|
|
@@ -226035,7 +226534,7 @@ function first_commit_default() {
|
|
|
226035
226534
|
}
|
|
226036
226535
|
};
|
|
226037
226536
|
}
|
|
226038
|
-
var init_first_commit =
|
|
226537
|
+
var init_first_commit = __esm2({
|
|
226039
226538
|
"src/lib/tasks/first-commit.ts"() {
|
|
226040
226539
|
init_utils();
|
|
226041
226540
|
init_task();
|
|
@@ -226048,7 +226547,7 @@ function hashObjectTask(filePath, write) {
|
|
|
226048
226547
|
}
|
|
226049
226548
|
return straightThroughStringTask(commands, true);
|
|
226050
226549
|
}
|
|
226051
|
-
var init_hash_object =
|
|
226550
|
+
var init_hash_object = __esm2({
|
|
226052
226551
|
"src/lib/tasks/hash-object.ts"() {
|
|
226053
226552
|
init_task();
|
|
226054
226553
|
}
|
|
@@ -226076,7 +226575,7 @@ function parseInit(bare, path3, text) {
|
|
|
226076
226575
|
var InitSummary;
|
|
226077
226576
|
var initResponseRegex;
|
|
226078
226577
|
var reInitResponseRegex;
|
|
226079
|
-
var init_InitSummary =
|
|
226578
|
+
var init_InitSummary = __esm2({
|
|
226080
226579
|
"src/lib/responses/InitSummary.ts"() {
|
|
226081
226580
|
InitSummary = class {
|
|
226082
226581
|
constructor(bare, path3, existing, gitDir) {
|
|
@@ -226107,7 +226606,7 @@ function initTask(bare = false, path3, customArgs) {
|
|
|
226107
226606
|
};
|
|
226108
226607
|
}
|
|
226109
226608
|
var bareCommand;
|
|
226110
|
-
var init_init =
|
|
226609
|
+
var init_init = __esm2({
|
|
226111
226610
|
"src/lib/tasks/init.ts"() {
|
|
226112
226611
|
init_InitSummary();
|
|
226113
226612
|
bareCommand = "--bare";
|
|
@@ -226126,13 +226625,13 @@ function isLogFormat(customArg) {
|
|
|
226126
226625
|
return logFormatRegex.test(customArg);
|
|
226127
226626
|
}
|
|
226128
226627
|
var logFormatRegex;
|
|
226129
|
-
var init_log_format =
|
|
226628
|
+
var init_log_format = __esm2({
|
|
226130
226629
|
"src/lib/args/log-format.ts"() {
|
|
226131
226630
|
logFormatRegex = /^--(stat|numstat|name-only|name-status)(=|$)/;
|
|
226132
226631
|
}
|
|
226133
226632
|
});
|
|
226134
226633
|
var DiffSummary;
|
|
226135
|
-
var init_DiffSummary =
|
|
226634
|
+
var init_DiffSummary = __esm2({
|
|
226136
226635
|
"src/lib/responses/DiffSummary.ts"() {
|
|
226137
226636
|
DiffSummary = class {
|
|
226138
226637
|
constructor() {
|
|
@@ -226153,7 +226652,7 @@ var numStatParser;
|
|
|
226153
226652
|
var nameOnlyParser;
|
|
226154
226653
|
var nameStatusParser;
|
|
226155
226654
|
var diffSummaryParsers;
|
|
226156
|
-
var init_parse_diff_summary =
|
|
226655
|
+
var init_parse_diff_summary = __esm2({
|
|
226157
226656
|
"src/lib/parsers/parse-diff-summary.ts"() {
|
|
226158
226657
|
init_log_format();
|
|
226159
226658
|
init_DiffSummary();
|
|
@@ -226274,7 +226773,7 @@ var START_BOUNDARY;
|
|
|
226274
226773
|
var COMMIT_BOUNDARY;
|
|
226275
226774
|
var SPLITTER;
|
|
226276
226775
|
var defaultFieldNames;
|
|
226277
|
-
var init_parse_list_log_summary =
|
|
226776
|
+
var init_parse_list_log_summary = __esm2({
|
|
226278
226777
|
"src/lib/parsers/parse-list-log-summary.ts"() {
|
|
226279
226778
|
init_utils();
|
|
226280
226779
|
init_parse_diff_summary();
|
|
@@ -226313,7 +226812,7 @@ function validateLogFormatConfig(customArgs) {
|
|
|
226313
226812
|
return configurationErrorTask(`Summary flag ${flags} parsing is not compatible with null termination option '-z'`);
|
|
226314
226813
|
}
|
|
226315
226814
|
}
|
|
226316
|
-
var init_diff =
|
|
226815
|
+
var init_diff = __esm2({
|
|
226317
226816
|
"src/lib/tasks/diff.ts"() {
|
|
226318
226817
|
init_log_format();
|
|
226319
226818
|
init_parse_diff_summary();
|
|
@@ -226397,7 +226896,7 @@ function log_default() {
|
|
|
226397
226896
|
}
|
|
226398
226897
|
}
|
|
226399
226898
|
var excludeOptions;
|
|
226400
|
-
var init_log =
|
|
226899
|
+
var init_log = __esm2({
|
|
226401
226900
|
"src/lib/tasks/log.ts"() {
|
|
226402
226901
|
init_log_format();
|
|
226403
226902
|
init_pathspec();
|
|
@@ -226425,7 +226924,7 @@ var init_log = __esm({
|
|
|
226425
226924
|
});
|
|
226426
226925
|
var MergeSummaryConflict;
|
|
226427
226926
|
var MergeSummaryDetail;
|
|
226428
|
-
var init_MergeSummary =
|
|
226927
|
+
var init_MergeSummary = __esm2({
|
|
226429
226928
|
"src/lib/responses/MergeSummary.ts"() {
|
|
226430
226929
|
MergeSummaryConflict = class {
|
|
226431
226930
|
constructor(reason, file = null, meta) {
|
|
@@ -226460,7 +226959,7 @@ var init_MergeSummary = __esm({
|
|
|
226460
226959
|
});
|
|
226461
226960
|
var PullSummary;
|
|
226462
226961
|
var PullFailedSummary;
|
|
226463
|
-
var init_PullSummary =
|
|
226962
|
+
var init_PullSummary = __esm2({
|
|
226464
226963
|
"src/lib/responses/PullSummary.ts"() {
|
|
226465
226964
|
PullSummary = class {
|
|
226466
226965
|
constructor() {
|
|
@@ -226517,7 +227016,7 @@ function asObjectCount(source) {
|
|
|
226517
227016
|
};
|
|
226518
227017
|
}
|
|
226519
227018
|
var remoteMessagesObjectParsers;
|
|
226520
|
-
var init_parse_remote_objects =
|
|
227019
|
+
var init_parse_remote_objects = __esm2({
|
|
226521
227020
|
"src/lib/parsers/parse-remote-objects.ts"() {
|
|
226522
227021
|
init_utils();
|
|
226523
227022
|
remoteMessagesObjectParsers = [
|
|
@@ -226545,7 +227044,7 @@ function parseRemoteMessages(_stdOut, stdErr) {
|
|
|
226545
227044
|
}
|
|
226546
227045
|
var parsers2;
|
|
226547
227046
|
var RemoteMessageSummary;
|
|
226548
|
-
var init_parse_remote_messages =
|
|
227047
|
+
var init_parse_remote_messages = __esm2({
|
|
226549
227048
|
"src/lib/parsers/parse-remote-messages.ts"() {
|
|
226550
227049
|
init_utils();
|
|
226551
227050
|
init_parse_remote_objects();
|
|
@@ -226584,7 +227083,7 @@ var parsers3;
|
|
|
226584
227083
|
var errorParsers;
|
|
226585
227084
|
var parsePullDetail;
|
|
226586
227085
|
var parsePullResult;
|
|
226587
|
-
var init_parse_pull =
|
|
227086
|
+
var init_parse_pull = __esm2({
|
|
226588
227087
|
"src/lib/parsers/parse-pull.ts"() {
|
|
226589
227088
|
init_PullSummary();
|
|
226590
227089
|
init_utils();
|
|
@@ -226637,7 +227136,7 @@ var init_parse_pull = __esm({
|
|
|
226637
227136
|
var parsers4;
|
|
226638
227137
|
var parseMergeResult;
|
|
226639
227138
|
var parseMergeDetail;
|
|
226640
|
-
var init_parse_merge =
|
|
227139
|
+
var init_parse_merge = __esm2({
|
|
226641
227140
|
"src/lib/parsers/parse-merge.ts"() {
|
|
226642
227141
|
init_MergeSummary();
|
|
226643
227142
|
init_utils();
|
|
@@ -226683,7 +227182,7 @@ function mergeTask(customArgs) {
|
|
|
226683
227182
|
}
|
|
226684
227183
|
};
|
|
226685
227184
|
}
|
|
226686
|
-
var init_merge =
|
|
227185
|
+
var init_merge = __esm2({
|
|
226687
227186
|
"src/lib/tasks/merge.ts"() {
|
|
226688
227187
|
init_git_response_error();
|
|
226689
227188
|
init_parse_merge();
|
|
@@ -226707,7 +227206,7 @@ function pushResultPushedItem(local, remote, status) {
|
|
|
226707
227206
|
var parsers5;
|
|
226708
227207
|
var parsePushResult;
|
|
226709
227208
|
var parsePushDetail;
|
|
226710
|
-
var init_parse_push =
|
|
227209
|
+
var init_parse_push = __esm2({
|
|
226711
227210
|
"src/lib/parsers/parse-push.ts"() {
|
|
226712
227211
|
init_utils();
|
|
226713
227212
|
init_parse_remote_messages();
|
|
@@ -226784,7 +227283,7 @@ function pushTask(ref = {}, customArgs) {
|
|
|
226784
227283
|
parser: parsePushResult
|
|
226785
227284
|
};
|
|
226786
227285
|
}
|
|
226787
|
-
var init_push =
|
|
227286
|
+
var init_push = __esm2({
|
|
226788
227287
|
"src/lib/tasks/push.ts"() {
|
|
226789
227288
|
init_parse_push();
|
|
226790
227289
|
init_utils();
|
|
@@ -226805,7 +227304,7 @@ function show_default() {
|
|
|
226805
227304
|
}
|
|
226806
227305
|
};
|
|
226807
227306
|
}
|
|
226808
|
-
var init_show =
|
|
227307
|
+
var init_show = __esm2({
|
|
226809
227308
|
"src/lib/tasks/show.ts"() {
|
|
226810
227309
|
init_utils();
|
|
226811
227310
|
init_task();
|
|
@@ -226813,7 +227312,7 @@ var init_show = __esm({
|
|
|
226813
227312
|
});
|
|
226814
227313
|
var fromPathRegex;
|
|
226815
227314
|
var FileStatusSummary;
|
|
226816
|
-
var init_FileStatusSummary =
|
|
227315
|
+
var init_FileStatusSummary = __esm2({
|
|
226817
227316
|
"src/lib/responses/FileStatusSummary.ts"() {
|
|
226818
227317
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
226819
227318
|
FileStatusSummary = class {
|
|
@@ -226867,7 +227366,7 @@ function splitLine(result, lineStr) {
|
|
|
226867
227366
|
var StatusSummary;
|
|
226868
227367
|
var parsers6;
|
|
226869
227368
|
var parseStatusSummary;
|
|
226870
|
-
var init_StatusSummary =
|
|
227369
|
+
var init_StatusSummary = __esm2({
|
|
226871
227370
|
"src/lib/responses/StatusSummary.ts"() {
|
|
226872
227371
|
init_utils();
|
|
226873
227372
|
init_FileStatusSummary();
|
|
@@ -226974,7 +227473,7 @@ function statusTask(customArgs) {
|
|
|
226974
227473
|
};
|
|
226975
227474
|
}
|
|
226976
227475
|
var ignoredOptions;
|
|
226977
|
-
var init_status =
|
|
227476
|
+
var init_status = __esm2({
|
|
226978
227477
|
"src/lib/tasks/status.ts"() {
|
|
226979
227478
|
init_StatusSummary();
|
|
226980
227479
|
ignoredOptions = ["--null", "-z"];
|
|
@@ -227023,7 +227522,7 @@ function versionParser(stdOut) {
|
|
|
227023
227522
|
}
|
|
227024
227523
|
var NOT_INSTALLED;
|
|
227025
227524
|
var parsers7;
|
|
227026
|
-
var init_version =
|
|
227525
|
+
var init_version = __esm2({
|
|
227027
227526
|
"src/lib/tasks/version.ts"() {
|
|
227028
227527
|
init_utils();
|
|
227029
227528
|
NOT_INSTALLED = "installed=false";
|
|
@@ -227042,7 +227541,7 @@ __export2(simple_git_api_exports, {
|
|
|
227042
227541
|
SimpleGitApi: () => SimpleGitApi
|
|
227043
227542
|
});
|
|
227044
227543
|
var SimpleGitApi;
|
|
227045
|
-
var init_simple_git_api =
|
|
227544
|
+
var init_simple_git_api = __esm2({
|
|
227046
227545
|
"src/lib/simple-git-api.ts"() {
|
|
227047
227546
|
init_task_callback();
|
|
227048
227547
|
init_change_working_directory();
|
|
@@ -227133,7 +227632,7 @@ __export2(scheduler_exports, {
|
|
|
227133
227632
|
});
|
|
227134
227633
|
var createScheduledTask;
|
|
227135
227634
|
var Scheduler;
|
|
227136
|
-
var init_scheduler =
|
|
227635
|
+
var init_scheduler = __esm2({
|
|
227137
227636
|
"src/lib/runners/scheduler.ts"() {
|
|
227138
227637
|
init_utils();
|
|
227139
227638
|
init_git_logger();
|
|
@@ -227186,7 +227685,7 @@ __export2(apply_patch_exports, {
|
|
|
227186
227685
|
function applyPatchTask(patches, customArgs) {
|
|
227187
227686
|
return straightThroughStringTask(["apply", ...customArgs, ...patches]);
|
|
227188
227687
|
}
|
|
227189
|
-
var init_apply_patch =
|
|
227688
|
+
var init_apply_patch = __esm2({
|
|
227190
227689
|
"src/lib/tasks/apply-patch.ts"() {
|
|
227191
227690
|
init_task();
|
|
227192
227691
|
}
|
|
@@ -227206,7 +227705,7 @@ function branchDeletionFailure(branch) {
|
|
|
227206
227705
|
};
|
|
227207
227706
|
}
|
|
227208
227707
|
var BranchDeletionBatch;
|
|
227209
|
-
var init_BranchDeleteSummary =
|
|
227708
|
+
var init_BranchDeleteSummary = __esm2({
|
|
227210
227709
|
"src/lib/responses/BranchDeleteSummary.ts"() {
|
|
227211
227710
|
BranchDeletionBatch = class {
|
|
227212
227711
|
constructor() {
|
|
@@ -227227,7 +227726,7 @@ var deleteSuccessRegex;
|
|
|
227227
227726
|
var deleteErrorRegex;
|
|
227228
227727
|
var parsers8;
|
|
227229
227728
|
var parseBranchDeletions;
|
|
227230
|
-
var init_parse_branch_delete =
|
|
227729
|
+
var init_parse_branch_delete = __esm2({
|
|
227231
227730
|
"src/lib/parsers/parse-branch-delete.ts"() {
|
|
227232
227731
|
init_BranchDeleteSummary();
|
|
227233
227732
|
init_utils();
|
|
@@ -227252,7 +227751,7 @@ var init_parse_branch_delete = __esm({
|
|
|
227252
227751
|
}
|
|
227253
227752
|
});
|
|
227254
227753
|
var BranchSummaryResult;
|
|
227255
|
-
var init_BranchSummary =
|
|
227754
|
+
var init_BranchSummary = __esm2({
|
|
227256
227755
|
"src/lib/responses/BranchSummary.ts"() {
|
|
227257
227756
|
BranchSummaryResult = class {
|
|
227258
227757
|
constructor() {
|
|
@@ -227285,7 +227784,7 @@ function parseBranchSummary(stdOut) {
|
|
|
227285
227784
|
return parseStringResponse(new BranchSummaryResult, parsers9, stdOut);
|
|
227286
227785
|
}
|
|
227287
227786
|
var parsers9;
|
|
227288
|
-
var init_parse_branch =
|
|
227787
|
+
var init_parse_branch = __esm2({
|
|
227289
227788
|
"src/lib/parsers/parse-branch.ts"() {
|
|
227290
227789
|
init_BranchSummary();
|
|
227291
227790
|
init_utils();
|
|
@@ -227370,7 +227869,7 @@ function deleteBranchTask(branch, forceDelete = false) {
|
|
|
227370
227869
|
};
|
|
227371
227870
|
return task;
|
|
227372
227871
|
}
|
|
227373
|
-
var init_branch =
|
|
227872
|
+
var init_branch = __esm2({
|
|
227374
227873
|
"src/lib/tasks/branch.ts"() {
|
|
227375
227874
|
init_git_response_error();
|
|
227376
227875
|
init_parse_branch_delete();
|
|
@@ -227379,7 +227878,7 @@ var init_branch = __esm({
|
|
|
227379
227878
|
}
|
|
227380
227879
|
});
|
|
227381
227880
|
var parseCheckIgnore;
|
|
227382
|
-
var init_CheckIgnore =
|
|
227881
|
+
var init_CheckIgnore = __esm2({
|
|
227383
227882
|
"src/lib/responses/CheckIgnore.ts"() {
|
|
227384
227883
|
parseCheckIgnore = (text) => {
|
|
227385
227884
|
return text.split(/\n/g).map((line) => line.trim()).filter((file) => !!file);
|
|
@@ -227397,7 +227896,7 @@ function checkIgnoreTask(paths) {
|
|
|
227397
227896
|
parser: parseCheckIgnore
|
|
227398
227897
|
};
|
|
227399
227898
|
}
|
|
227400
|
-
var init_check_ignore =
|
|
227899
|
+
var init_check_ignore = __esm2({
|
|
227401
227900
|
"src/lib/tasks/check-ignore.ts"() {
|
|
227402
227901
|
init_CheckIgnore();
|
|
227403
227902
|
}
|
|
@@ -227424,7 +227923,7 @@ function cloneMirrorTask(repo, directory, customArgs) {
|
|
|
227424
227923
|
append2(customArgs, "--mirror");
|
|
227425
227924
|
return cloneTask(repo, directory, customArgs);
|
|
227426
227925
|
}
|
|
227427
|
-
var init_clone =
|
|
227926
|
+
var init_clone = __esm2({
|
|
227428
227927
|
"src/lib/tasks/clone.ts"() {
|
|
227429
227928
|
init_task();
|
|
227430
227929
|
init_utils();
|
|
@@ -227442,7 +227941,7 @@ function parseFetchResult(stdOut, stdErr) {
|
|
|
227442
227941
|
return parseStringResponse(result, parsers10, [stdOut, stdErr]);
|
|
227443
227942
|
}
|
|
227444
227943
|
var parsers10;
|
|
227445
|
-
var init_parse_fetch =
|
|
227944
|
+
var init_parse_fetch = __esm2({
|
|
227446
227945
|
"src/lib/parsers/parse-fetch.ts"() {
|
|
227447
227946
|
init_utils();
|
|
227448
227947
|
parsers10 = [
|
|
@@ -227499,7 +227998,7 @@ function fetchTask(remote, branch, customArgs) {
|
|
|
227499
227998
|
parser: parseFetchResult
|
|
227500
227999
|
};
|
|
227501
228000
|
}
|
|
227502
|
-
var init_fetch =
|
|
228001
|
+
var init_fetch = __esm2({
|
|
227503
228002
|
"src/lib/tasks/fetch.ts"() {
|
|
227504
228003
|
init_parse_fetch();
|
|
227505
228004
|
init_task();
|
|
@@ -227509,7 +228008,7 @@ function parseMoveResult(stdOut) {
|
|
|
227509
228008
|
return parseStringResponse({ moves: [] }, parsers11, stdOut);
|
|
227510
228009
|
}
|
|
227511
228010
|
var parsers11;
|
|
227512
|
-
var init_parse_move =
|
|
228011
|
+
var init_parse_move = __esm2({
|
|
227513
228012
|
"src/lib/parsers/parse-move.ts"() {
|
|
227514
228013
|
init_utils();
|
|
227515
228014
|
parsers11 = [
|
|
@@ -227530,7 +228029,7 @@ function moveTask(from, to) {
|
|
|
227530
228029
|
parser: parseMoveResult
|
|
227531
228030
|
};
|
|
227532
228031
|
}
|
|
227533
|
-
var init_move =
|
|
228032
|
+
var init_move = __esm2({
|
|
227534
228033
|
"src/lib/tasks/move.ts"() {
|
|
227535
228034
|
init_parse_move();
|
|
227536
228035
|
init_utils();
|
|
@@ -227560,7 +228059,7 @@ function pullTask(remote, branch, customArgs) {
|
|
|
227560
228059
|
}
|
|
227561
228060
|
};
|
|
227562
228061
|
}
|
|
227563
|
-
var init_pull =
|
|
228062
|
+
var init_pull = __esm2({
|
|
227564
228063
|
"src/lib/tasks/pull.ts"() {
|
|
227565
228064
|
init_git_response_error();
|
|
227566
228065
|
init_parse_pull();
|
|
@@ -227590,7 +228089,7 @@ function parseGetRemotesVerbose(text) {
|
|
|
227590
228089
|
function forEach2(text, handler) {
|
|
227591
228090
|
forEachLineWithContent(text, (line) => handler(line.split(/\s+/)));
|
|
227592
228091
|
}
|
|
227593
|
-
var init_GetRemoteSummary =
|
|
228092
|
+
var init_GetRemoteSummary = __esm2({
|
|
227594
228093
|
"src/lib/responses/GetRemoteSummary.ts"() {
|
|
227595
228094
|
init_utils();
|
|
227596
228095
|
}
|
|
@@ -227634,7 +228133,7 @@ function remoteTask(customArgs) {
|
|
|
227634
228133
|
function removeRemoteTask(remoteName) {
|
|
227635
228134
|
return straightThroughStringTask(["remote", "remove", remoteName]);
|
|
227636
228135
|
}
|
|
227637
|
-
var init_remote =
|
|
228136
|
+
var init_remote = __esm2({
|
|
227638
228137
|
"src/lib/tasks/remote.ts"() {
|
|
227639
228138
|
init_GetRemoteSummary();
|
|
227640
228139
|
init_task();
|
|
@@ -227654,7 +228153,7 @@ function stashListTask(opt = {}, customArgs) {
|
|
|
227654
228153
|
parser: parser4
|
|
227655
228154
|
};
|
|
227656
228155
|
}
|
|
227657
|
-
var init_stash_list =
|
|
228156
|
+
var init_stash_list = __esm2({
|
|
227658
228157
|
"src/lib/tasks/stash-list.ts"() {
|
|
227659
228158
|
init_log_format();
|
|
227660
228159
|
init_parse_list_log_summary();
|
|
@@ -227685,7 +228184,7 @@ function subModuleTask(customArgs) {
|
|
|
227685
228184
|
function updateSubModuleTask(customArgs) {
|
|
227686
228185
|
return subModuleTask(["update", ...customArgs]);
|
|
227687
228186
|
}
|
|
227688
|
-
var init_sub_module =
|
|
228187
|
+
var init_sub_module = __esm2({
|
|
227689
228188
|
"src/lib/tasks/sub-module.ts"() {
|
|
227690
228189
|
init_task();
|
|
227691
228190
|
}
|
|
@@ -227712,7 +228211,7 @@ function toNumber(input) {
|
|
|
227712
228211
|
}
|
|
227713
228212
|
var TagList;
|
|
227714
228213
|
var parseTagList;
|
|
227715
|
-
var init_TagList =
|
|
228214
|
+
var init_TagList = __esm2({
|
|
227716
228215
|
"src/lib/responses/TagList.ts"() {
|
|
227717
228216
|
TagList = class {
|
|
227718
228217
|
constructor(all3, latest) {
|
|
@@ -227778,7 +228277,7 @@ function addAnnotatedTagTask(name, tagMessage) {
|
|
|
227778
228277
|
}
|
|
227779
228278
|
};
|
|
227780
228279
|
}
|
|
227781
|
-
var init_tag =
|
|
228280
|
+
var init_tag = __esm2({
|
|
227782
228281
|
"src/lib/tasks/tag.ts"() {
|
|
227783
228282
|
init_TagList();
|
|
227784
228283
|
}
|
|
@@ -228454,6 +228953,8 @@ var esm_default2 = gitInstanceFactory;
|
|
|
228454
228953
|
import { Writable } from "stream";
|
|
228455
228954
|
|
|
228456
228955
|
// src/config.ts
|
|
228956
|
+
init_constants();
|
|
228957
|
+
init_logger();
|
|
228457
228958
|
import fs2 from "fs";
|
|
228458
228959
|
import path3 from "path";
|
|
228459
228960
|
import { fileURLToPath } from "url";
|
|
@@ -228711,7 +229212,12 @@ var getProcessedPublisherConfig = (serverRoot) => {
|
|
|
228711
229212
|
};
|
|
228712
229213
|
};
|
|
228713
229214
|
|
|
229215
|
+
// src/service/environment_store.ts
|
|
229216
|
+
init_constants();
|
|
229217
|
+
init_errors();
|
|
229218
|
+
|
|
228714
229219
|
// src/health.ts
|
|
229220
|
+
init_logger();
|
|
228715
229221
|
var operationalState = "initializing";
|
|
228716
229222
|
var ready = false;
|
|
228717
229223
|
var preGracefulShutdownCompleted = false;
|
|
@@ -228767,6 +229273,11 @@ async function performGracefulShutdownAfterDrain(server, mcpServer, shutdownGrac
|
|
|
228767
229273
|
await shutdownSDK();
|
|
228768
229274
|
logger.info("OpenTelemetry SDK shut down");
|
|
228769
229275
|
} catch (_error) {}
|
|
229276
|
+
try {
|
|
229277
|
+
const { getPackageLoadPool: getPackageLoadPool2 } = await Promise.resolve().then(() => (init_package_load_pool(), exports_package_load_pool));
|
|
229278
|
+
await getPackageLoadPool2().shutdown();
|
|
229279
|
+
logger.info("Package-load worker pool shut down");
|
|
229280
|
+
} catch (_error) {}
|
|
228770
229281
|
if (shutdownGracefulCloseTimeoutSeconds > 0) {
|
|
228771
229282
|
logger.info(`Waiting ${shutdownGracefulCloseTimeoutSeconds} seconds after server close before exit...`);
|
|
228772
229283
|
await new Promise((resolve3) => setTimeout(resolve3, shutdownGracefulCloseTimeoutSeconds * 1000));
|
|
@@ -228808,7 +229319,12 @@ function registerHealthEndpoints(app) {
|
|
|
228808
229319
|
});
|
|
228809
229320
|
}
|
|
228810
229321
|
|
|
229322
|
+
// src/service/environment_store.ts
|
|
229323
|
+
init_logger();
|
|
229324
|
+
|
|
228811
229325
|
// src/storage/StorageManager.ts
|
|
229326
|
+
init_errors();
|
|
229327
|
+
init_logger();
|
|
228812
229328
|
import * as crypto3 from "crypto";
|
|
228813
229329
|
|
|
228814
229330
|
// src/storage/duckdb/DuckDBConnection.ts
|
|
@@ -229615,6 +230131,7 @@ class DuckDBRepository {
|
|
|
229615
230131
|
}
|
|
229616
230132
|
|
|
229617
230133
|
// src/storage/duckdb/schema.ts
|
|
230134
|
+
init_logger();
|
|
229618
230135
|
async function initializeSchema(db, force = false) {
|
|
229619
230136
|
const initialized = await db.isInitialized();
|
|
229620
230137
|
if (initialized && !force) {
|
|
@@ -229743,6 +230260,8 @@ async function dropAllTables(db) {
|
|
|
229743
230260
|
}
|
|
229744
230261
|
|
|
229745
230262
|
// src/storage/ducklake/DuckLakeManifestStore.ts
|
|
230263
|
+
init_logger();
|
|
230264
|
+
|
|
229746
230265
|
class DuckLakeManifestStore {
|
|
229747
230266
|
db;
|
|
229748
230267
|
table;
|
|
@@ -229969,12 +230488,16 @@ class StorageManager {
|
|
|
229969
230488
|
}
|
|
229970
230489
|
|
|
229971
230490
|
// src/service/environment.ts
|
|
229972
|
-
import { MalloyError as
|
|
230491
|
+
import { MalloyError as MalloyError4, Runtime as Runtime2 } from "@malloydata/malloy";
|
|
230492
|
+
init_constants();
|
|
230493
|
+
init_errors();
|
|
230494
|
+
init_logger();
|
|
229973
230495
|
import crypto4 from "crypto";
|
|
229974
230496
|
import * as fs6 from "fs";
|
|
229975
230497
|
import * as path9 from "path";
|
|
229976
230498
|
|
|
229977
230499
|
// src/path_safety.ts
|
|
230500
|
+
init_errors();
|
|
229978
230501
|
import * as path5 from "path";
|
|
229979
230502
|
var SAFE_NAME_RE = /^(?!\.\.?$)(?!\.)[A-Za-z0-9._-]{1,255}$/;
|
|
229980
230503
|
var MAX_MODEL_PATH_LEN = 1024;
|
|
@@ -230029,12 +230552,12 @@ function safeJoinUnderRoot(root, ...segments) {
|
|
|
230029
230552
|
// src/utils.ts
|
|
230030
230553
|
import * as fs3 from "fs";
|
|
230031
230554
|
import * as path6 from "path";
|
|
230032
|
-
import { fileURLToPath as
|
|
230555
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
230033
230556
|
var URL_READER = {
|
|
230034
230557
|
readURL: (url2) => {
|
|
230035
230558
|
let path7 = url2.toString();
|
|
230036
230559
|
if (url2.protocol == "file:") {
|
|
230037
|
-
path7 =
|
|
230560
|
+
path7 = fileURLToPath3(url2);
|
|
230038
230561
|
}
|
|
230039
230562
|
return fs3.promises.readFile(path7, "utf8");
|
|
230040
230563
|
}
|
|
@@ -230044,17 +230567,27 @@ function ignoreDotfiles(file) {
|
|
|
230044
230567
|
}
|
|
230045
230568
|
|
|
230046
230569
|
// src/service/package.ts
|
|
230570
|
+
init_package_load_pool();
|
|
230571
|
+
init_constants();
|
|
230572
|
+
init_errors();
|
|
230573
|
+
init_logger();
|
|
230047
230574
|
var import_api3 = __toESM(require_src(), 1);
|
|
230048
230575
|
var import_recursive_readdir = __toESM(require_recursive_readdir(), 1);
|
|
230049
230576
|
import * as fs5 from "fs/promises";
|
|
230050
230577
|
import * as path8 from "path";
|
|
230578
|
+
import"@malloydata/db-duckdb/native";
|
|
230051
230579
|
import {
|
|
230580
|
+
ConnectionRuntime,
|
|
230052
230581
|
contextOverlay as contextOverlay2,
|
|
230582
|
+
EmptyURLReader,
|
|
230053
230583
|
FixedConnectionMap as FixedConnectionMap2,
|
|
230054
|
-
MalloyConfig as MalloyConfig3
|
|
230584
|
+
MalloyConfig as MalloyConfig3,
|
|
230585
|
+
MalloyError as MalloyError3
|
|
230055
230586
|
} from "@malloydata/malloy";
|
|
230056
230587
|
|
|
230057
230588
|
// src/service/model.ts
|
|
230589
|
+
init_package_load_pool();
|
|
230590
|
+
init_constants();
|
|
230058
230591
|
var import_api2 = __toESM(require_src(), 1);
|
|
230059
230592
|
import {
|
|
230060
230593
|
API,
|
|
@@ -230074,6 +230607,7 @@ import { createRequire as createRequire2 } from "module";
|
|
|
230074
230607
|
import * as path7 from "path";
|
|
230075
230608
|
|
|
230076
230609
|
// src/data_styles.ts
|
|
230610
|
+
init_logger();
|
|
230077
230611
|
function compileDataStyles(styles) {
|
|
230078
230612
|
try {
|
|
230079
230613
|
return JSON.parse(styles);
|
|
@@ -230120,6 +230654,10 @@ class HackyDataStylesAccumulator {
|
|
|
230120
230654
|
}
|
|
230121
230655
|
}
|
|
230122
230656
|
|
|
230657
|
+
// src/service/model.ts
|
|
230658
|
+
init_errors();
|
|
230659
|
+
init_logger();
|
|
230660
|
+
|
|
230123
230661
|
// src/service/filter.ts
|
|
230124
230662
|
var VALID_FILTER_TYPES = new Set([
|
|
230125
230663
|
"equal",
|
|
@@ -230310,8 +230848,7 @@ function tokenize(input) {
|
|
|
230310
230848
|
return tokens;
|
|
230311
230849
|
}
|
|
230312
230850
|
|
|
230313
|
-
// src/service/
|
|
230314
|
-
var MALLOY_VERSION = createRequire2(import.meta.url)("@malloydata/malloy/package.json").version;
|
|
230851
|
+
// src/service/given.ts
|
|
230315
230852
|
function malloyGivenToApi(given) {
|
|
230316
230853
|
const type = given.type;
|
|
230317
230854
|
const renderedType = type.type === "filter expression" ? `filter<${type.filterType}>` : type.type;
|
|
@@ -230322,6 +230859,9 @@ function malloyGivenToApi(given) {
|
|
|
230322
230859
|
};
|
|
230323
230860
|
}
|
|
230324
230861
|
|
|
230862
|
+
// src/service/model.ts
|
|
230863
|
+
var MALLOY_VERSION = createRequire2(import.meta.url)("@malloydata/malloy/package.json").version;
|
|
230864
|
+
|
|
230325
230865
|
class Model {
|
|
230326
230866
|
packageName;
|
|
230327
230867
|
modelPath;
|
|
@@ -230342,7 +230882,7 @@ class Model {
|
|
|
230342
230882
|
description: "How long it takes to execute a Malloy model query",
|
|
230343
230883
|
unit: "ms"
|
|
230344
230884
|
});
|
|
230345
|
-
constructor(packageName, modelPath, dataStyles, modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, compilationError, filterMap, givens) {
|
|
230885
|
+
constructor(packageName, modelPath, dataStyles, modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, compilationError, filterMap, givens, modelInfo) {
|
|
230346
230886
|
this.packageName = packageName;
|
|
230347
230887
|
this.modelPath = modelPath;
|
|
230348
230888
|
this.dataStyles = dataStyles;
|
|
@@ -230356,7 +230896,7 @@ class Model {
|
|
|
230356
230896
|
this.compilationError = compilationError;
|
|
230357
230897
|
this.filterMap = filterMap ?? new Map;
|
|
230358
230898
|
this.givens = givens;
|
|
230359
|
-
this.modelInfo = this.modelDef ? modelDefToModelInfo(this.modelDef) : undefined;
|
|
230899
|
+
this.modelInfo = modelInfo ?? (this.modelDef ? modelDefToModelInfo(this.modelDef) : undefined);
|
|
230360
230900
|
}
|
|
230361
230901
|
getFilters(sourceName) {
|
|
230362
230902
|
return this.filterMap.get(sourceName) ?? [];
|
|
@@ -230432,6 +230972,27 @@ class Model {
|
|
|
230432
230972
|
return new Model(packageName, modelPath, dataStyles, modelType, undefined, undefined, undefined, undefined, undefined, undefined, computedError);
|
|
230433
230973
|
}
|
|
230434
230974
|
}
|
|
230975
|
+
static fromSerialized(packageName, _packagePath, malloyConfig, data) {
|
|
230976
|
+
const modelDef = data.modelDef;
|
|
230977
|
+
const modelInfo = data.modelInfo;
|
|
230978
|
+
const dataStyles = data.dataStyles ?? {};
|
|
230979
|
+
const sources = data.sources;
|
|
230980
|
+
const queries = data.queries;
|
|
230981
|
+
const sourceInfos = data.sourceInfos;
|
|
230982
|
+
const givens = data.givens;
|
|
230983
|
+
const filterMap = data.filterMap ? new Map(data.filterMap) : undefined;
|
|
230984
|
+
if (!modelDef) {
|
|
230985
|
+
return new Model(packageName, data.modelPath, dataStyles, data.modelType, undefined, undefined, sources, queries, sourceInfos, data.modelType === "notebook" ? hydrateMarkdownOnlyCells(data.notebookCells) : undefined, undefined, filterMap, givens, modelInfo);
|
|
230986
|
+
}
|
|
230987
|
+
const runtime = makeHydrationRuntime(malloyConfig);
|
|
230988
|
+
const modelMaterializer = runtime._loadModelFromModelDef(modelDef);
|
|
230989
|
+
const runnableNotebookCells = data.modelType === "notebook" ? hydrateNotebookCells(runtime, data.notebookCells) : undefined;
|
|
230990
|
+
return new Model(packageName, data.modelPath, dataStyles, data.modelType, modelMaterializer, modelDef, sources, queries, sourceInfos, runnableNotebookCells, undefined, filterMap, givens, modelInfo);
|
|
230991
|
+
}
|
|
230992
|
+
static fromCompilationError(packageName, modelPath, modelType, error) {
|
|
230993
|
+
return new Model(packageName, modelPath, {}, modelType, undefined, undefined, undefined, undefined, undefined, undefined, error);
|
|
230994
|
+
}
|
|
230995
|
+
static deserializeCompilationError = deserializeError;
|
|
230435
230996
|
getPath() {
|
|
230436
230997
|
return this.modelPath;
|
|
230437
230998
|
}
|
|
@@ -230590,7 +231151,7 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
230590
231151
|
malloyVersion: MALLOY_VERSION,
|
|
230591
231152
|
dataStyles: JSON.stringify(this.dataStyles),
|
|
230592
231153
|
modelDef: JSON.stringify(this.modelDef),
|
|
230593
|
-
modelInfo: JSON.stringify(this.
|
|
231154
|
+
modelInfo: JSON.stringify(this.modelInfo ?? {}),
|
|
230594
231155
|
sourceInfos: this.getSourceInfos()?.map((sourceInfo) => JSON.stringify(sourceInfo)),
|
|
230595
231156
|
sources: this.sources,
|
|
230596
231157
|
queries: this.queries,
|
|
@@ -230622,7 +231183,7 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
230622
231183
|
packageName: this.packageName,
|
|
230623
231184
|
modelPath: this.modelPath,
|
|
230624
231185
|
malloyVersion: MALLOY_VERSION,
|
|
230625
|
-
modelInfo: JSON.stringify(this.
|
|
231186
|
+
modelInfo: JSON.stringify(this.modelInfo ?? {}),
|
|
230626
231187
|
sources: this.modelDef && this.sources,
|
|
230627
231188
|
queries: this.modelDef && this.queries,
|
|
230628
231189
|
annotations: allAnnotations,
|
|
@@ -230920,166 +231481,55 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
230920
231481
|
}
|
|
230921
231482
|
}
|
|
230922
231483
|
}
|
|
230923
|
-
|
|
230924
|
-
|
|
230925
|
-
|
|
230926
|
-
|
|
230927
|
-
|
|
230928
|
-
|
|
230929
|
-
|
|
230930
|
-
|
|
230931
|
-
|
|
230932
|
-
|
|
230933
|
-
|
|
230934
|
-
|
|
230935
|
-
|
|
230936
|
-
|
|
230937
|
-
|
|
230938
|
-
this.workerUrl = workerUrl;
|
|
230939
|
-
this.size = size;
|
|
230940
|
-
}
|
|
230941
|
-
start() {
|
|
230942
|
-
if (this.workers.length > 0)
|
|
230943
|
-
return;
|
|
230944
|
-
for (let i = 0;i < this.size; i++) {
|
|
230945
|
-
this.workers.push(this.spawn(i));
|
|
230946
|
-
}
|
|
230947
|
-
logger.info(`SchemaWorkerPool started (size=${this.size})`);
|
|
230948
|
-
}
|
|
230949
|
-
async stop() {
|
|
230950
|
-
this.stopped = true;
|
|
230951
|
-
const shutdownError = new Error("SchemaWorkerPool stopped");
|
|
230952
|
-
for (const req of this.queue.splice(0))
|
|
230953
|
-
req.reject(shutdownError);
|
|
230954
|
-
for (const req of this.inFlight.values())
|
|
230955
|
-
req.reject(shutdownError);
|
|
230956
|
-
this.inFlight.clear();
|
|
230957
|
-
await Promise.all(this.workers.map(async (slot) => {
|
|
230958
|
-
try {
|
|
230959
|
-
await slot.worker.terminate();
|
|
230960
|
-
} catch {}
|
|
230961
|
-
}));
|
|
230962
|
-
this.workers.length = 0;
|
|
230963
|
-
}
|
|
230964
|
-
submit(packagePath, databasePath) {
|
|
230965
|
-
if (this.stopped) {
|
|
230966
|
-
return Promise.reject(new Error("SchemaWorkerPool stopped"));
|
|
230967
|
-
}
|
|
230968
|
-
if (this.workers.length === 0) {
|
|
230969
|
-
return Promise.reject(new Error("SchemaWorkerPool.submit called before start()"));
|
|
230970
|
-
}
|
|
230971
|
-
return new Promise((resolve4, reject) => {
|
|
230972
|
-
const req = {
|
|
230973
|
-
id: this.nextId++,
|
|
230974
|
-
packagePath,
|
|
230975
|
-
databasePath,
|
|
230976
|
-
resolve: resolve4,
|
|
230977
|
-
reject
|
|
230978
|
-
};
|
|
230979
|
-
this.queue.push(req);
|
|
230980
|
-
this.drain();
|
|
230981
|
-
});
|
|
230982
|
-
}
|
|
230983
|
-
drain() {
|
|
230984
|
-
for (let i = 0;i < this.workers.length; i++) {
|
|
230985
|
-
if (this.queue.length === 0)
|
|
230986
|
-
return;
|
|
230987
|
-
const slot = this.workers[i];
|
|
230988
|
-
if (slot.busy)
|
|
230989
|
-
continue;
|
|
230990
|
-
const req = this.queue.shift();
|
|
230991
|
-
slot.busy = true;
|
|
230992
|
-
this.inFlight.set(req.id, req);
|
|
230993
|
-
this.workerCurrentId.set(i, req.id);
|
|
230994
|
-
slot.worker.postMessage({
|
|
230995
|
-
id: req.id,
|
|
230996
|
-
packagePath: req.packagePath,
|
|
230997
|
-
databasePath: req.databasePath
|
|
230998
|
-
});
|
|
231484
|
+
function makeHydrationRuntime(malloyConfig) {
|
|
231485
|
+
const urlReader = new HackyDataStylesAccumulator(URL_READER);
|
|
231486
|
+
const config = malloyConfig instanceof MalloyConfig2 ? malloyConfig : (() => {
|
|
231487
|
+
const c = new MalloyConfig2({ connections: {} });
|
|
231488
|
+
c.wrapConnections(() => new FixedConnectionMap(malloyConfig, "duckdb"));
|
|
231489
|
+
return c;
|
|
231490
|
+
})();
|
|
231491
|
+
return new Runtime({ urlReader, config });
|
|
231492
|
+
}
|
|
231493
|
+
function hydrateNotebookCells(runtime, notebookCells) {
|
|
231494
|
+
if (!notebookCells)
|
|
231495
|
+
return [];
|
|
231496
|
+
return notebookCells.map((sc) => {
|
|
231497
|
+
if (sc.type === "markdown") {
|
|
231498
|
+
return { type: "markdown", text: sc.text };
|
|
230999
231499
|
}
|
|
231000
|
-
|
|
231001
|
-
|
|
231002
|
-
|
|
231003
|
-
|
|
231004
|
-
|
|
231005
|
-
|
|
231006
|
-
|
|
231007
|
-
|
|
231008
|
-
|
|
231009
|
-
|
|
231010
|
-
|
|
231011
|
-
|
|
231012
|
-
}
|
|
231013
|
-
this.inFlight.delete(msg.id);
|
|
231014
|
-
this.workerCurrentId.delete(index);
|
|
231015
|
-
slot.busy = false;
|
|
231016
|
-
if (msg.ok && msg.result) {
|
|
231017
|
-
req.resolve(msg.result);
|
|
231018
|
-
} else {
|
|
231019
|
-
const err = new Error(msg.error?.message ?? "Unknown error");
|
|
231020
|
-
if (msg.error?.stack)
|
|
231021
|
-
err.stack = msg.error.stack;
|
|
231022
|
-
req.reject(err);
|
|
231023
|
-
}
|
|
231024
|
-
this.drain();
|
|
231025
|
-
});
|
|
231026
|
-
worker.on("error", (err) => {
|
|
231027
|
-
const inFlightId = this.workerCurrentId.get(index);
|
|
231028
|
-
if (inFlightId !== undefined) {
|
|
231029
|
-
const req = this.inFlight.get(inFlightId);
|
|
231030
|
-
if (req) {
|
|
231031
|
-
this.inFlight.delete(inFlightId);
|
|
231032
|
-
req.reject(err);
|
|
231033
|
-
}
|
|
231034
|
-
this.workerCurrentId.delete(index);
|
|
231035
|
-
}
|
|
231036
|
-
logger.error("SchemaWorkerPool: worker errored", {
|
|
231037
|
-
workerIndex: index,
|
|
231038
|
-
error: err
|
|
231039
|
-
});
|
|
231040
|
-
});
|
|
231041
|
-
worker.on("exit", (code) => {
|
|
231042
|
-
if (this.stopped)
|
|
231043
|
-
return;
|
|
231044
|
-
const inFlightId = this.workerCurrentId.get(index);
|
|
231045
|
-
if (inFlightId !== undefined) {
|
|
231046
|
-
const req = this.inFlight.get(inFlightId);
|
|
231047
|
-
if (req) {
|
|
231048
|
-
this.inFlight.delete(inFlightId);
|
|
231049
|
-
req.reject(new Error(`SchemaWorker exited with code ${code}`));
|
|
231500
|
+
const cellModelDef = sc.cellModelDef;
|
|
231501
|
+
let modelMaterializer;
|
|
231502
|
+
let runnable;
|
|
231503
|
+
if (cellModelDef) {
|
|
231504
|
+
modelMaterializer = runtime._loadModelFromModelDef(cellModelDef);
|
|
231505
|
+
if (sc.cellQueryDef !== undefined) {
|
|
231506
|
+
try {
|
|
231507
|
+
runnable = modelMaterializer._loadQueryFromQueryDef(sc.cellQueryDef);
|
|
231508
|
+
} catch (error) {
|
|
231509
|
+
logger.warn("Failed to hydrate notebook cell queryDef", {
|
|
231510
|
+
error
|
|
231511
|
+
});
|
|
231050
231512
|
}
|
|
231051
|
-
this.workerCurrentId.delete(index);
|
|
231052
231513
|
}
|
|
231053
|
-
|
|
231054
|
-
|
|
231055
|
-
|
|
231056
|
-
|
|
231057
|
-
|
|
231058
|
-
|
|
231059
|
-
|
|
231060
|
-
|
|
231061
|
-
|
|
231062
|
-
|
|
231063
|
-
this.workers[index] = this.spawn(index);
|
|
231064
|
-
this.drain();
|
|
231065
|
-
});
|
|
231066
|
-
return slot;
|
|
231067
|
-
}
|
|
231068
|
-
}
|
|
231069
|
-
var singleton = null;
|
|
231070
|
-
function getSchemaWorkerPool() {
|
|
231071
|
-
if (!singleton) {
|
|
231072
|
-
const url2 = resolveWorkerUrl();
|
|
231073
|
-
const size = Number(process.env.PUBLISHER_SCHEMA_WORKER_POOL_SIZE) || 2;
|
|
231074
|
-
singleton = new SchemaWorkerPool(url2, size);
|
|
231075
|
-
singleton.start();
|
|
231076
|
-
}
|
|
231077
|
-
return singleton;
|
|
231514
|
+
}
|
|
231515
|
+
return {
|
|
231516
|
+
type: "code",
|
|
231517
|
+
text: sc.text,
|
|
231518
|
+
runnable,
|
|
231519
|
+
modelMaterializer,
|
|
231520
|
+
newSources: sc.newSources,
|
|
231521
|
+
queryInfo: sc.queryInfo
|
|
231522
|
+
};
|
|
231523
|
+
});
|
|
231078
231524
|
}
|
|
231079
|
-
function
|
|
231080
|
-
|
|
231081
|
-
|
|
231082
|
-
return
|
|
231525
|
+
function hydrateMarkdownOnlyCells(notebookCells) {
|
|
231526
|
+
if (!notebookCells)
|
|
231527
|
+
return;
|
|
231528
|
+
return notebookCells.map((sc) => {
|
|
231529
|
+
if (sc.type === "markdown")
|
|
231530
|
+
return { type: "markdown", text: sc.text };
|
|
231531
|
+
return { type: "code", text: sc.text };
|
|
231532
|
+
});
|
|
231083
231533
|
}
|
|
231084
231534
|
|
|
231085
231535
|
// src/service/package.ts
|
|
@@ -231115,74 +231565,19 @@ class Package {
|
|
|
231115
231565
|
packageName,
|
|
231116
231566
|
duration: formatDuration(manifestValidationTime - startTime)
|
|
231117
231567
|
});
|
|
231118
|
-
let packageMalloyConfig;
|
|
231119
231568
|
try {
|
|
231120
|
-
const packageConfig = await Package.readPackageConfig(packagePath);
|
|
231121
|
-
const packageConfigTime = performance.now();
|
|
231122
|
-
logger.info("Package config read completed", {
|
|
231123
|
-
packageName,
|
|
231124
|
-
duration: formatDuration(packageConfigTime - manifestValidationTime)
|
|
231125
|
-
});
|
|
231126
|
-
packageConfig.resource = `${API_PREFIX}/environments/${environmentName}/packages/${packageName}`;
|
|
231127
|
-
const databases = await Package.readDatabases(packagePath);
|
|
231128
|
-
const databasesTime = performance.now();
|
|
231129
|
-
logger.info("Databases read completed", {
|
|
231130
|
-
packageName,
|
|
231131
|
-
databaseCount: databases.length,
|
|
231132
|
-
duration: formatDuration(databasesTime - packageConfigTime)
|
|
231133
|
-
});
|
|
231134
231569
|
const malloyConfig = Package.buildPackageMalloyConfig(packagePath, typeof environmentMalloyConfig === "function" ? environmentMalloyConfig : () => Package.toMalloyConfig(environmentMalloyConfig));
|
|
231135
|
-
|
|
231136
|
-
const modelsTime = performance.now();
|
|
231137
|
-
logger.info("Models loaded", {
|
|
231138
|
-
packageName,
|
|
231139
|
-
modelCount: models.size,
|
|
231140
|
-
duration: formatDuration(modelsTime - databasesTime)
|
|
231141
|
-
});
|
|
231142
|
-
for (const [modelPath, model] of models.entries()) {
|
|
231143
|
-
const maybeModel = model;
|
|
231144
|
-
if (maybeModel.compilationError) {
|
|
231145
|
-
const err = maybeModel.compilationError;
|
|
231146
|
-
const message = err instanceof Error ? err.message : `Unknown compilation error in ${modelPath}`;
|
|
231147
|
-
logger.error("Model compilation failed", {
|
|
231148
|
-
packageName,
|
|
231149
|
-
modelPath,
|
|
231150
|
-
error: message
|
|
231151
|
-
});
|
|
231152
|
-
this.packageLoadHistogram.record(performance.now() - startTime, {
|
|
231153
|
-
malloy_package_name: packageName,
|
|
231154
|
-
status: "compilation_error"
|
|
231155
|
-
});
|
|
231156
|
-
throw err;
|
|
231157
|
-
}
|
|
231158
|
-
}
|
|
231159
|
-
const endTime = performance.now();
|
|
231160
|
-
const executionTime = endTime - startTime;
|
|
231161
|
-
this.packageLoadHistogram.record(executionTime, {
|
|
231162
|
-
malloy_package_name: packageName,
|
|
231163
|
-
status: "success"
|
|
231164
|
-
});
|
|
231165
|
-
logger.info(`Successfully loaded package ${packageName}`, {
|
|
231166
|
-
packageName,
|
|
231167
|
-
duration: formatDuration(executionTime)
|
|
231168
|
-
});
|
|
231169
|
-
return new Package(environmentName, packageName, packagePath, packageConfig, databases, models, malloyConfig);
|
|
231570
|
+
return await Package.loadViaWorker(environmentName, packageName, packagePath, malloyConfig, startTime, manifestValidationTime);
|
|
231170
231571
|
} catch (error) {
|
|
231171
231572
|
logger.error(`Error loading package ${packageName}`, { error });
|
|
231172
231573
|
console.error(error);
|
|
231173
231574
|
const endTime = performance.now();
|
|
231174
231575
|
const executionTime = endTime - startTime;
|
|
231576
|
+
const status = error instanceof ModelCompilationError || error instanceof MalloyError3 ? "compilation_error" : error instanceof ServiceUnavailableError ? "pool_unavailable" : "error";
|
|
231175
231577
|
this.packageLoadHistogram.record(executionTime, {
|
|
231176
231578
|
malloy_package_name: packageName,
|
|
231177
|
-
status
|
|
231579
|
+
status
|
|
231178
231580
|
});
|
|
231179
|
-
if (packageMalloyConfig) {
|
|
231180
|
-
try {
|
|
231181
|
-
await packageMalloyConfig.shutdown("close");
|
|
231182
|
-
} catch (releaseError) {
|
|
231183
|
-
logger.warn(`Failed to release package-local DuckDB for ${packageName}`, { error: releaseError });
|
|
231184
|
-
}
|
|
231185
|
-
}
|
|
231186
231581
|
try {
|
|
231187
231582
|
await fs5.rm(packagePath, {
|
|
231188
231583
|
recursive: true,
|
|
@@ -231197,6 +231592,64 @@ class Package {
|
|
|
231197
231592
|
throw error;
|
|
231198
231593
|
}
|
|
231199
231594
|
}
|
|
231595
|
+
static async loadViaWorker(environmentName, packageName, packagePath, malloyConfig, startTime, manifestValidationTime) {
|
|
231596
|
+
const pool = getPackageLoadPool();
|
|
231597
|
+
const dispatchTime = performance.now();
|
|
231598
|
+
const workerOutcome = pool.loadPackage({
|
|
231599
|
+
packagePath,
|
|
231600
|
+
packageName,
|
|
231601
|
+
malloyConfig,
|
|
231602
|
+
defaultConnectionName: "duckdb"
|
|
231603
|
+
}).catch((err) => {
|
|
231604
|
+
const realError = err instanceof Error ? err : new Error(`Package-load worker pool failure: ${String(err)}`);
|
|
231605
|
+
if (realError instanceof MalloyError3 || realError instanceof ModelCompilationError) {
|
|
231606
|
+
throw realError;
|
|
231607
|
+
}
|
|
231608
|
+
throw new ServiceUnavailableError(`Package-load worker pool unavailable: ${realError.message}`);
|
|
231609
|
+
});
|
|
231610
|
+
const [outcome, databases] = await Promise.all([
|
|
231611
|
+
workerOutcome,
|
|
231612
|
+
Package.readDatabases(packagePath, malloyConfig)
|
|
231613
|
+
]);
|
|
231614
|
+
const workerDoneTime = performance.now();
|
|
231615
|
+
logger.info("Package load via worker pool completed", {
|
|
231616
|
+
packageName,
|
|
231617
|
+
manifestValidationMs: dispatchTime - manifestValidationTime,
|
|
231618
|
+
workerDurationMs: outcome.loadDurationMs,
|
|
231619
|
+
dispatchOverheadMs: workerDoneTime - dispatchTime - outcome.loadDurationMs,
|
|
231620
|
+
modelCount: outcome.models.length,
|
|
231621
|
+
databaseCount: databases.length
|
|
231622
|
+
});
|
|
231623
|
+
const packageConfig = {
|
|
231624
|
+
name: outcome.packageMetadata.name,
|
|
231625
|
+
description: outcome.packageMetadata.description,
|
|
231626
|
+
resource: `${API_PREFIX}/environments/${environmentName}/packages/${packageName}`
|
|
231627
|
+
};
|
|
231628
|
+
const models = new Map;
|
|
231629
|
+
for (const sm of outcome.models) {
|
|
231630
|
+
if (sm.compilationError) {
|
|
231631
|
+
const err = Model.deserializeCompilationError(sm.compilationError);
|
|
231632
|
+
logger.error("Model compilation failed", {
|
|
231633
|
+
packageName,
|
|
231634
|
+
modelPath: sm.modelPath,
|
|
231635
|
+
error: err.message
|
|
231636
|
+
});
|
|
231637
|
+
throw err;
|
|
231638
|
+
}
|
|
231639
|
+
models.set(sm.modelPath, Model.fromSerialized(packageName, packagePath, malloyConfig, sm));
|
|
231640
|
+
}
|
|
231641
|
+
const endTime = performance.now();
|
|
231642
|
+
const executionTime = endTime - startTime;
|
|
231643
|
+
this.packageLoadHistogram.record(executionTime, {
|
|
231644
|
+
malloy_package_name: packageName,
|
|
231645
|
+
status: "success"
|
|
231646
|
+
});
|
|
231647
|
+
logger.info(`Successfully loaded package ${packageName}`, {
|
|
231648
|
+
packageName,
|
|
231649
|
+
duration: formatDuration(executionTime)
|
|
231650
|
+
});
|
|
231651
|
+
return new Package(environmentName, packageName, packagePath, packageConfig, databases, models, malloyConfig);
|
|
231652
|
+
}
|
|
231200
231653
|
getPackageName() {
|
|
231201
231654
|
return this.packageName;
|
|
231202
231655
|
}
|
|
@@ -231228,10 +231681,36 @@ class Package {
|
|
|
231228
231681
|
modelCount: modelPaths.length,
|
|
231229
231682
|
manifestEntryCount: Object.keys(buildManifest).length
|
|
231230
231683
|
});
|
|
231231
|
-
const
|
|
231684
|
+
const pool = getPackageLoadPool();
|
|
231685
|
+
let outcome;
|
|
231686
|
+
try {
|
|
231687
|
+
outcome = await pool.loadPackage({
|
|
231688
|
+
packagePath: this.packagePath,
|
|
231689
|
+
packageName: this.packageName,
|
|
231690
|
+
malloyConfig: this.malloyConfig,
|
|
231691
|
+
defaultConnectionName: "duckdb",
|
|
231692
|
+
buildManifest
|
|
231693
|
+
});
|
|
231694
|
+
} catch (err) {
|
|
231695
|
+
const realError = err instanceof Error ? err : new Error(`Package-load worker pool failure: ${String(err)}`);
|
|
231696
|
+
if (realError instanceof MalloyError3 || realError instanceof ModelCompilationError) {
|
|
231697
|
+
throw realError;
|
|
231698
|
+
}
|
|
231699
|
+
throw new ServiceUnavailableError(`Package-load worker pool unavailable: ${realError.message}`);
|
|
231700
|
+
}
|
|
231232
231701
|
const nextModels = new Map;
|
|
231233
|
-
for (const
|
|
231234
|
-
|
|
231702
|
+
for (const sm of outcome.models) {
|
|
231703
|
+
if (sm.compilationError) {
|
|
231704
|
+
const err = Model.deserializeCompilationError(sm.compilationError);
|
|
231705
|
+
logger.warn("Model compilation failed during reload", {
|
|
231706
|
+
packageName: this.packageName,
|
|
231707
|
+
modelPath: sm.modelPath,
|
|
231708
|
+
error: err.message
|
|
231709
|
+
});
|
|
231710
|
+
nextModels.set(sm.modelPath, Model.fromCompilationError(this.packageName, sm.modelPath, sm.modelType, err));
|
|
231711
|
+
} else {
|
|
231712
|
+
nextModels.set(sm.modelPath, Model.fromSerialized(this.packageName, this.packagePath, this.malloyConfig, sm));
|
|
231713
|
+
}
|
|
231235
231714
|
}
|
|
231236
231715
|
this.models = nextModels;
|
|
231237
231716
|
}
|
|
@@ -231279,11 +231758,6 @@ class Package {
|
|
|
231279
231758
|
};
|
|
231280
231759
|
}));
|
|
231281
231760
|
}
|
|
231282
|
-
static async loadModels(packageName, packagePath, malloyConfig) {
|
|
231283
|
-
const modelPaths = await Package.getModelPaths(packagePath);
|
|
231284
|
-
const models = await Promise.all(modelPaths.map((modelPath) => Model.create(packageName, packagePath, modelPath, malloyConfig)));
|
|
231285
|
-
return new Map(models.map((model) => [model.getPath(), model]));
|
|
231286
|
-
}
|
|
231287
231761
|
static buildPackageMalloyConfig(packagePath, getEnvironmentMalloyConfig) {
|
|
231288
231762
|
const malloyConfig = new MalloyConfig3({
|
|
231289
231763
|
connections: {
|
|
@@ -231313,18 +231787,6 @@ class Package {
|
|
|
231313
231787
|
malloyConfig.wrapConnections(() => new FixedConnectionMap2(input, "duckdb"));
|
|
231314
231788
|
return malloyConfig;
|
|
231315
231789
|
}
|
|
231316
|
-
static async getModelPaths(packagePath) {
|
|
231317
|
-
let files = undefined;
|
|
231318
|
-
try {
|
|
231319
|
-
files = await import_recursive_readdir.default(packagePath, [ignoreDotfiles]);
|
|
231320
|
-
} catch (error) {
|
|
231321
|
-
logger.error(error);
|
|
231322
|
-
throw new PackageNotFoundError(`Package config for ${packagePath} does not exist.`);
|
|
231323
|
-
}
|
|
231324
|
-
return files.map((fullPath) => {
|
|
231325
|
-
return path8.relative(packagePath, fullPath).replace(/\\/g, "/");
|
|
231326
|
-
}).filter((modelPath) => modelPath.endsWith(MODEL_FILE_SUFFIX) || modelPath.endsWith(NOTEBOOK_FILE_SUFFIX));
|
|
231327
|
-
}
|
|
231328
231790
|
static async validatePackageManifestExistsOrThrowError(packagePath) {
|
|
231329
231791
|
const packageConfigPath = path8.join(packagePath, PACKAGE_MANIFEST_NAME);
|
|
231330
231792
|
try {
|
|
@@ -231334,39 +231796,17 @@ class Package {
|
|
|
231334
231796
|
throw new PackageNotFoundError(`Package manifest for ${packagePath} does not exist.`);
|
|
231335
231797
|
}
|
|
231336
231798
|
}
|
|
231337
|
-
static async
|
|
231338
|
-
const packageConfigPath = path8.join(packagePath, PACKAGE_MANIFEST_NAME);
|
|
231339
|
-
const packageConfigContents = await fs5.readFile(packageConfigPath);
|
|
231340
|
-
const packageManifest = JSON.parse(packageConfigContents.toString());
|
|
231341
|
-
return {
|
|
231342
|
-
name: packageManifest.name,
|
|
231343
|
-
description: packageManifest.description
|
|
231344
|
-
};
|
|
231345
|
-
}
|
|
231346
|
-
static async readDatabases(packagePath) {
|
|
231799
|
+
static async readDatabases(packagePath, malloyConfig) {
|
|
231347
231800
|
const databasePaths = await Package.getDatabasePaths(packagePath);
|
|
231348
|
-
if (databasePaths.length === 0)
|
|
231801
|
+
if (databasePaths.length === 0) {
|
|
231349
231802
|
return [];
|
|
231350
|
-
const pool = getSchemaWorkerPool();
|
|
231351
|
-
const settled = await Promise.allSettled(databasePaths.map((databasePath) => pool.submit(packagePath, databasePath)));
|
|
231352
|
-
const results = [];
|
|
231353
|
-
for (let i = 0;i < settled.length; i++) {
|
|
231354
|
-
const outcome = settled[i];
|
|
231355
|
-
if (outcome.status === "fulfilled") {
|
|
231356
|
-
results.push({
|
|
231357
|
-
path: databasePaths[i],
|
|
231358
|
-
info: outcome.value,
|
|
231359
|
-
type: "embedded"
|
|
231360
|
-
});
|
|
231361
|
-
} else {
|
|
231362
|
-
logger.warn("Schema introspection failed for database", {
|
|
231363
|
-
packagePath,
|
|
231364
|
-
databasePath: databasePaths[i],
|
|
231365
|
-
error: outcome.reason
|
|
231366
|
-
});
|
|
231367
|
-
}
|
|
231368
231803
|
}
|
|
231369
|
-
|
|
231804
|
+
const conn = await malloyConfig.connections.lookupConnection("duckdb");
|
|
231805
|
+
return await Promise.all(databasePaths.map(async (databasePath) => ({
|
|
231806
|
+
path: databasePath,
|
|
231807
|
+
info: await Package.getDatabaseInfo(packagePath, databasePath, conn),
|
|
231808
|
+
type: "embedded"
|
|
231809
|
+
})));
|
|
231370
231810
|
}
|
|
231371
231811
|
static async getDatabasePaths(packagePath) {
|
|
231372
231812
|
const files = await import_recursive_readdir.default(packagePath, [ignoreDotfiles]);
|
|
@@ -231374,6 +231814,24 @@ class Package {
|
|
|
231374
231814
|
return path8.relative(packagePath, fullPath).replace(/\\/g, "/");
|
|
231375
231815
|
}).filter((modelPath) => modelPath.endsWith(".parquet") || modelPath.endsWith(".csv"));
|
|
231376
231816
|
}
|
|
231817
|
+
static async getDatabaseInfo(packagePath, databasePath, conn) {
|
|
231818
|
+
const fullPath = path8.join(packagePath, databasePath);
|
|
231819
|
+
const runtime = new ConnectionRuntime({
|
|
231820
|
+
urlReader: new EmptyURLReader,
|
|
231821
|
+
connections: [conn]
|
|
231822
|
+
});
|
|
231823
|
+
const normalizedPath = fullPath.replace(/\\/g, "/");
|
|
231824
|
+
const model = runtime.loadModel(`source: temp is duckdb.table('${normalizedPath}')`);
|
|
231825
|
+
const modelDef = await model.getModel();
|
|
231826
|
+
const fields = modelDef._modelDef.contents["temp"].fields;
|
|
231827
|
+
const schema = fields.map((field) => {
|
|
231828
|
+
return { type: field.type, name: field.name };
|
|
231829
|
+
});
|
|
231830
|
+
const runner = model.loadQuery("run: temp->{aggregate: row_count is count()}");
|
|
231831
|
+
const result = await runner.run();
|
|
231832
|
+
const rowCount = result.data.value[0].row_count?.valueOf();
|
|
231833
|
+
return { name: databasePath, rowCount, columns: schema };
|
|
231834
|
+
}
|
|
231377
231835
|
setName(name) {
|
|
231378
231836
|
this.packageName = name;
|
|
231379
231837
|
}
|
|
@@ -231515,7 +231973,7 @@ ${source}` : source;
|
|
|
231515
231973
|
}
|
|
231516
231974
|
return { problems: model.problems, sql };
|
|
231517
231975
|
} catch (error) {
|
|
231518
|
-
if (error instanceof
|
|
231976
|
+
if (error instanceof MalloyError4) {
|
|
231519
231977
|
return { problems: error.problems };
|
|
231520
231978
|
}
|
|
231521
231979
|
throw error;
|
|
@@ -232342,10 +232800,6 @@ class EnvironmentStore {
|
|
|
232342
232800
|
return Promise.all(Array.from(this.environments.values()).map((environment) => environment.serialize()));
|
|
232343
232801
|
}
|
|
232344
232802
|
async getStatus() {
|
|
232345
|
-
const memoryGovernorStatus = this.memoryGovernor?.getStatus() ?? null;
|
|
232346
|
-
logger.info("Memory governor status", {
|
|
232347
|
-
memoryGovernor: memoryGovernorStatus
|
|
232348
|
-
});
|
|
232349
232803
|
const status = {
|
|
232350
232804
|
timestamp: Date.now(),
|
|
232351
232805
|
environments: [],
|
|
@@ -232999,7 +233453,12 @@ class WatchModeController {
|
|
|
232999
233453
|
};
|
|
233000
233454
|
}
|
|
233001
233455
|
|
|
233456
|
+
// src/server.ts
|
|
233457
|
+
init_errors();
|
|
233458
|
+
init_logger();
|
|
233459
|
+
|
|
233002
233460
|
// src/service/resolve_environment.ts
|
|
233461
|
+
init_errors();
|
|
233003
233462
|
async function resolveEnvironmentId(repository, environmentName) {
|
|
233004
233463
|
const dbEnvironment = await repository.getEnvironmentByName(environmentName);
|
|
233005
233464
|
if (!dbEnvironment) {
|
|
@@ -233031,6 +233490,8 @@ class ManifestController {
|
|
|
233031
233490
|
}
|
|
233032
233491
|
|
|
233033
233492
|
// src/controller/materialization.controller.ts
|
|
233493
|
+
init_errors();
|
|
233494
|
+
|
|
233034
233495
|
class MaterializationController {
|
|
233035
233496
|
materializationService;
|
|
233036
233497
|
constructor(materializationService) {
|
|
@@ -235717,6 +236178,12 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
235717
236178
|
}
|
|
235718
236179
|
};
|
|
235719
236180
|
|
|
236181
|
+
// src/mcp/server.ts
|
|
236182
|
+
init_logger();
|
|
236183
|
+
|
|
236184
|
+
// src/mcp/prompts/prompt_service.ts
|
|
236185
|
+
init_logger();
|
|
236186
|
+
|
|
235720
236187
|
// src/mcp/prompts/handlers.ts
|
|
235721
236188
|
var import_handlebars = __toESM(require_lib8(), 1);
|
|
235722
236189
|
|
|
@@ -235911,6 +236378,9 @@ function registerPromptCapability(mcpServer, environmentStore) {
|
|
|
235911
236378
|
logger.info(`[MCP Init] Finished registering prompts. Registered: ${registeredCount}`, { duration: endTime - startTime });
|
|
235912
236379
|
}
|
|
235913
236380
|
|
|
236381
|
+
// src/mcp/resources/environment_resource.ts
|
|
236382
|
+
init_logger();
|
|
236383
|
+
|
|
235914
236384
|
// src/mcp/error_messages.ts
|
|
235915
236385
|
function getNotFoundError(resourceUriOrContext) {
|
|
235916
236386
|
const baseMessage = `Resource not found: ${resourceUriOrContext}`;
|
|
@@ -236000,6 +236470,9 @@ function getMalloyErrorDetails(operation, modelIdentifier, error) {
|
|
|
236000
236470
|
}
|
|
236001
236471
|
|
|
236002
236472
|
// src/mcp/handler_utils.ts
|
|
236473
|
+
init_errors();
|
|
236474
|
+
init_logger();
|
|
236475
|
+
|
|
236003
236476
|
class McpGetResourceError extends Error {
|
|
236004
236477
|
details;
|
|
236005
236478
|
constructor(details) {
|
|
@@ -236212,6 +236685,7 @@ function registerEnvironmentResource(mcpServer, environmentStore) {
|
|
|
236212
236685
|
}
|
|
236213
236686
|
|
|
236214
236687
|
// src/mcp/resources/model_resource.ts
|
|
236688
|
+
init_errors();
|
|
236215
236689
|
function registerModelResource(mcpServer, environmentStore) {
|
|
236216
236690
|
mcpServer.resource("model", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "model", async ({
|
|
236217
236691
|
environmentName,
|
|
@@ -236271,6 +236745,8 @@ function registerModelResource(mcpServer, environmentStore) {
|
|
|
236271
236745
|
}
|
|
236272
236746
|
|
|
236273
236747
|
// src/mcp/resources/notebook_resource.ts
|
|
236748
|
+
init_errors();
|
|
236749
|
+
init_logger();
|
|
236274
236750
|
function registerNotebookResource(mcpServer, environmentStore) {
|
|
236275
236751
|
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) => {
|
|
236276
236752
|
if (typeof environmentName !== "string" || typeof packageName !== "string" || typeof notebookName !== "string") {
|
|
@@ -236310,6 +236786,8 @@ function registerNotebookResource(mcpServer, environmentStore) {
|
|
|
236310
236786
|
}
|
|
236311
236787
|
|
|
236312
236788
|
// src/mcp/resources/package_resource.ts
|
|
236789
|
+
init_errors();
|
|
236790
|
+
init_logger();
|
|
236313
236791
|
async function handleGetPackageContents(uri, params, environmentStore) {
|
|
236314
236792
|
try {
|
|
236315
236793
|
const { environmentName, packageName } = params;
|
|
@@ -236502,6 +236980,8 @@ function registerPackageResource(mcpServer, environmentStore) {
|
|
|
236502
236980
|
}
|
|
236503
236981
|
|
|
236504
236982
|
// src/mcp/resources/query_resource.ts
|
|
236983
|
+
init_errors();
|
|
236984
|
+
init_logger();
|
|
236505
236985
|
function registerQueryResource(mcpServer, environmentStore) {
|
|
236506
236986
|
mcpServer.resource("query", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/queries/{queryName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "query", async ({
|
|
236507
236987
|
environmentName,
|
|
@@ -236544,6 +237024,8 @@ function registerQueryResource(mcpServer, environmentStore) {
|
|
|
236544
237024
|
}
|
|
236545
237025
|
|
|
236546
237026
|
// src/mcp/resources/source_resource.ts
|
|
237027
|
+
init_errors();
|
|
237028
|
+
init_logger();
|
|
236547
237029
|
function registerSourceResource(mcpServer, environmentStore) {
|
|
236548
237030
|
mcpServer.resource("source", new ResourceTemplate("malloy://environment/{environmentName}/package/{packageName}/models/{modelPath}/sources/{sourceName}", { list: undefined }), (uri, params) => handleResourceGet(uri, params, "source", async ({
|
|
236549
237031
|
environmentName,
|
|
@@ -236589,6 +237071,8 @@ function registerSourceResource(mcpServer, environmentStore) {
|
|
|
236589
237071
|
}
|
|
236590
237072
|
|
|
236591
237073
|
// src/mcp/resources/view_resource.ts
|
|
237074
|
+
init_errors();
|
|
237075
|
+
init_logger();
|
|
236592
237076
|
function registerViewResource(mcpServer, environmentStore) {
|
|
236593
237077
|
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 ({
|
|
236594
237078
|
environmentName,
|
|
@@ -236786,6 +237270,9 @@ function registerTools(mcpServer, environmentStore) {
|
|
|
236786
237270
|
});
|
|
236787
237271
|
}
|
|
236788
237272
|
|
|
237273
|
+
// src/mcp/tools/execute_query_tool.ts
|
|
237274
|
+
init_logger();
|
|
237275
|
+
|
|
236789
237276
|
// src/mcp/mcp_constants.ts
|
|
236790
237277
|
var MCP_ERROR_MESSAGES = {
|
|
236791
237278
|
MISSING_REQUIRED_PARAMS: "Either 'query' or both 'sourceName' and 'queryName' must be provided",
|
|
@@ -236992,6 +237479,8 @@ function initializeMcpServer(environmentStore) {
|
|
|
236992
237479
|
}
|
|
236993
237480
|
|
|
236994
237481
|
// src/server-old.ts
|
|
237482
|
+
init_errors();
|
|
237483
|
+
init_logger();
|
|
236995
237484
|
var import_body_parser = __toESM(require_body_parser(), 1);
|
|
236996
237485
|
var LEGACY_API_PREFIX = "/api/v0";
|
|
236997
237486
|
function remapMaterializationResponse(mat) {
|
|
@@ -237567,6 +238056,8 @@ function registerLegacyRoutes(app, controllers) {
|
|
|
237567
238056
|
}
|
|
237568
238057
|
|
|
237569
238058
|
// src/service/manifest_service.ts
|
|
238059
|
+
init_logger();
|
|
238060
|
+
|
|
237570
238061
|
class ManifestService {
|
|
237571
238062
|
environmentStore;
|
|
237572
238063
|
constructor(environmentStore) {
|
|
@@ -237602,9 +238093,12 @@ class ManifestService {
|
|
|
237602
238093
|
}
|
|
237603
238094
|
|
|
237604
238095
|
// src/service/materialization_service.ts
|
|
238096
|
+
init_errors();
|
|
238097
|
+
init_logger();
|
|
237605
238098
|
import { Manifest } from "@malloydata/malloy";
|
|
237606
238099
|
|
|
237607
238100
|
// src/service/materialized_table_gc.ts
|
|
238101
|
+
init_logger();
|
|
237608
238102
|
import {
|
|
237609
238103
|
DatabricksDialect,
|
|
237610
238104
|
DuckDBDialect,
|
|
@@ -238206,6 +238700,7 @@ class MaterializationService {
|
|
|
238206
238700
|
}
|
|
238207
238701
|
|
|
238208
238702
|
// src/service/package_memory_governor.ts
|
|
238703
|
+
init_logger();
|
|
238209
238704
|
var import_api4 = __toESM(require_src(), 1);
|
|
238210
238705
|
var DEFAULT_RSS_SAMPLER = () => process.memoryUsage().rss;
|
|
238211
238706
|
|
|
@@ -238306,118 +238801,6 @@ class PackageMemoryGovernor {
|
|
|
238306
238801
|
}
|
|
238307
238802
|
}
|
|
238308
238803
|
|
|
238309
|
-
// src/service/process_stats_reporter.ts
|
|
238310
|
-
import * as fs8 from "fs";
|
|
238311
|
-
var DEFAULT_INTERVAL_MS = 30000;
|
|
238312
|
-
function readLinuxProcStatus() {
|
|
238313
|
-
try {
|
|
238314
|
-
const raw = fs8.readFileSync("/proc/self/status", "utf8");
|
|
238315
|
-
const out = {};
|
|
238316
|
-
for (const line of raw.split(`
|
|
238317
|
-
`)) {
|
|
238318
|
-
const [keyRaw, valueRaw] = line.split(":");
|
|
238319
|
-
if (!keyRaw || !valueRaw)
|
|
238320
|
-
continue;
|
|
238321
|
-
const key = keyRaw.trim();
|
|
238322
|
-
const value = valueRaw.trim();
|
|
238323
|
-
switch (key) {
|
|
238324
|
-
case "Threads":
|
|
238325
|
-
out.threads = Number(value);
|
|
238326
|
-
break;
|
|
238327
|
-
case "VmRSS":
|
|
238328
|
-
out.vmRssBytes = kBToBytes(value);
|
|
238329
|
-
break;
|
|
238330
|
-
case "VmSize":
|
|
238331
|
-
out.vmSizeBytes = kBToBytes(value);
|
|
238332
|
-
break;
|
|
238333
|
-
case "VmPeak":
|
|
238334
|
-
out.vmPeakBytes = kBToBytes(value);
|
|
238335
|
-
break;
|
|
238336
|
-
case "VmData":
|
|
238337
|
-
out.vmDataBytes = kBToBytes(value);
|
|
238338
|
-
break;
|
|
238339
|
-
case "voluntary_ctxt_switches":
|
|
238340
|
-
out.voluntaryCtxSwitches = Number(value);
|
|
238341
|
-
break;
|
|
238342
|
-
case "nonvoluntary_ctxt_switches":
|
|
238343
|
-
out.nonvoluntaryCtxSwitches = Number(value);
|
|
238344
|
-
break;
|
|
238345
|
-
}
|
|
238346
|
-
}
|
|
238347
|
-
return out;
|
|
238348
|
-
} catch {
|
|
238349
|
-
return null;
|
|
238350
|
-
}
|
|
238351
|
-
}
|
|
238352
|
-
function kBToBytes(value) {
|
|
238353
|
-
const num = Number(value.replace(/\s*kB$/, ""));
|
|
238354
|
-
if (!Number.isFinite(num))
|
|
238355
|
-
return;
|
|
238356
|
-
return num * 1024;
|
|
238357
|
-
}
|
|
238358
|
-
async function readBunJscStats() {
|
|
238359
|
-
if (typeof globalThis.Bun === "undefined") {
|
|
238360
|
-
return null;
|
|
238361
|
-
}
|
|
238362
|
-
try {
|
|
238363
|
-
const jsc = await import("bun:jsc");
|
|
238364
|
-
const heap = jsc.heapStats?.();
|
|
238365
|
-
const mem = jsc.memoryUsage?.();
|
|
238366
|
-
if (!heap && !mem)
|
|
238367
|
-
return null;
|
|
238368
|
-
return { ...heap ?? {}, ...mem ?? {} };
|
|
238369
|
-
} catch {
|
|
238370
|
-
return null;
|
|
238371
|
-
}
|
|
238372
|
-
}
|
|
238373
|
-
|
|
238374
|
-
class ProcessStatsReporter {
|
|
238375
|
-
timer = null;
|
|
238376
|
-
intervalMs;
|
|
238377
|
-
memoryGovernor;
|
|
238378
|
-
constructor(memoryGovernor, intervalMs = DEFAULT_INTERVAL_MS) {
|
|
238379
|
-
this.memoryGovernor = memoryGovernor;
|
|
238380
|
-
this.intervalMs = intervalMs;
|
|
238381
|
-
}
|
|
238382
|
-
start() {
|
|
238383
|
-
if (this.timer !== null)
|
|
238384
|
-
return;
|
|
238385
|
-
this.tick();
|
|
238386
|
-
this.timer = setInterval(() => void this.tick(), this.intervalMs);
|
|
238387
|
-
this.timer.unref?.();
|
|
238388
|
-
logger.info(`ProcessStatsReporter started (intervalMs=${this.intervalMs})`);
|
|
238389
|
-
}
|
|
238390
|
-
stop() {
|
|
238391
|
-
if (this.timer !== null) {
|
|
238392
|
-
clearInterval(this.timer);
|
|
238393
|
-
this.timer = null;
|
|
238394
|
-
}
|
|
238395
|
-
}
|
|
238396
|
-
async tick() {
|
|
238397
|
-
try {
|
|
238398
|
-
const mem = process.memoryUsage();
|
|
238399
|
-
const proc = process.platform === "linux" ? readLinuxProcStatus() : null;
|
|
238400
|
-
const bun = await readBunJscStats();
|
|
238401
|
-
const governor = this.memoryGovernor?.getStatus() ?? null;
|
|
238402
|
-
logger.info("process stats", {
|
|
238403
|
-
uptimeSeconds: Math.round(process.uptime()),
|
|
238404
|
-
nodeMemory: {
|
|
238405
|
-
rssBytes: mem.rss,
|
|
238406
|
-
heapTotalBytes: mem.heapTotal,
|
|
238407
|
-
heapUsedBytes: mem.heapUsed,
|
|
238408
|
-
externalBytes: mem.external,
|
|
238409
|
-
arrayBuffersBytes: mem.arrayBuffers
|
|
238410
|
-
},
|
|
238411
|
-
linux: proc,
|
|
238412
|
-
bunJsc: bun,
|
|
238413
|
-
memoryGovernor: governor
|
|
238414
|
-
});
|
|
238415
|
-
} catch (err) {
|
|
238416
|
-
logger.warn("ProcessStatsReporter tick failed", { error: err });
|
|
238417
|
-
}
|
|
238418
|
-
}
|
|
238419
|
-
}
|
|
238420
|
-
|
|
238421
238804
|
// src/server.ts
|
|
238422
238805
|
function normalizeQueryArray(value) {
|
|
238423
238806
|
if (value === undefined || value === null)
|
|
@@ -238486,7 +238869,7 @@ var MCP_PORT = Number(process.env.MCP_PORT || 4040);
|
|
|
238486
238869
|
var MCP_ENDPOINT = "/mcp";
|
|
238487
238870
|
var SHUTDOWN_DRAIN_DURATION_SECONDS = Number(process.env.SHUTDOWN_DRAIN_DURATION_SECONDS || 0);
|
|
238488
238871
|
var SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS = Number(process.env.SHUTDOWN_GRACEFUL_CLOSE_TIMEOUT_SECONDS || 0);
|
|
238489
|
-
var __filename_esm =
|
|
238872
|
+
var __filename_esm = fileURLToPath4(import.meta.url);
|
|
238490
238873
|
var ROOT = path12.join(path12.dirname(__filename_esm), "app");
|
|
238491
238874
|
var SERVER_ROOT = path12.resolve(process.cwd(), process.env.SERVER_ROOT || ".");
|
|
238492
238875
|
var API_PREFIX2 = "/api/v0";
|
|
@@ -238503,8 +238886,6 @@ var memoryGovernorConfig = getMemoryGovernorConfig();
|
|
|
238503
238886
|
var memoryGovernor = memoryGovernorConfig ? new PackageMemoryGovernor(memoryGovernorConfig) : null;
|
|
238504
238887
|
memoryGovernor?.start();
|
|
238505
238888
|
environmentStore.setMemoryGovernor(memoryGovernor);
|
|
238506
|
-
var processStatsReporter = new ProcessStatsReporter(memoryGovernor);
|
|
238507
|
-
processStatsReporter.start();
|
|
238508
238889
|
var packageController = new PackageController(environmentStore, manifestService);
|
|
238509
238890
|
var databaseController = new DatabaseController(environmentStore);
|
|
238510
238891
|
var queryController = new QueryController(environmentStore);
|
|
@@ -239200,6 +239581,10 @@ app.use((err, _req, res, _next) => {
|
|
|
239200
239581
|
const { json, status } = internalErrorToHttpError(err);
|
|
239201
239582
|
res.status(status).json(json);
|
|
239202
239583
|
});
|
|
239584
|
+
{
|
|
239585
|
+
const { getPackageLoadPool: getPackageLoadPool2 } = await Promise.resolve().then(() => (init_package_load_pool(), exports_package_load_pool));
|
|
239586
|
+
getPackageLoadPool2();
|
|
239587
|
+
}
|
|
239203
239588
|
var mainServer = http2.createServer({ maxHeaderSize: 262144 }, app);
|
|
239204
239589
|
mainServer.timeout = 600000;
|
|
239205
239590
|
mainServer.keepAliveTimeout = 600000;
|