@malloy-publisher/server 0.0.226 → 0.0.228
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/README.docker.md +8 -8
- package/README.md +2 -11
- package/dist/app/assets/{EnvironmentPage-DvOJ7L_b.js → EnvironmentPage-EW2lbGvb.js} +1 -1
- package/dist/app/assets/{HomePage-CXguJsXS.js → HomePage-Bkwc9Woc.js} +1 -1
- package/dist/app/assets/{LightMode-ZsshUznu.js → LightMode-Bum_KBpN.js} +1 -1
- package/dist/app/assets/{MainPage-BIe0VwBa.js → MainPage-oiEy7TNM.js} +1 -1
- package/dist/app/assets/{MaterializationsPage-BuZ6UJVx.js → MaterializationsPage-C_VJsTgU.js} +1 -1
- package/dist/app/assets/{ModelPage-DsPf-s8B.js → ModelPage-z8REqAmk.js} +1 -1
- package/dist/app/assets/{PackagePage-CEVNAKZa.js → PackagePage-C2Vtt1Ln.js} +1 -1
- package/dist/app/assets/{RouteError-Chn7lL96.js → RouteError-DmJLpLXm.js} +1 -1
- package/dist/app/assets/{ThemeEditorPage-DWC_FdNU.js → ThemeEditorPage-BywFjC7A.js} +1 -1
- package/dist/app/assets/{WorkbookPage-CGrsFz8p.js → WorkbookPage-DCMizDMR.js} +1 -1
- package/dist/app/assets/{core-vVgoO8IR.es-BD_THWs_.js → core-CEDZMHV1.es-_yGzNgNH.js} +1 -1
- package/dist/app/assets/{index-D6YtyiJ0.js → index-CE9xhdra.js} +1 -1
- package/dist/app/assets/{index-BioohWQj.js → index-CdmFub34.js} +1 -1
- package/dist/app/assets/{index-gEWxu09x.js → index-DDMrjIT3.js} +1 -1
- package/dist/app/assets/{index-DNUZpnaa.js → index-EqslXZ44.js} +4 -4
- package/dist/app/index.html +1 -1
- package/dist/default-publisher.config.json +7 -7
- package/dist/package_load_worker.mjs +86 -24
- package/dist/runtime/publisher.js +5 -0
- package/dist/server.mjs +1415 -7876
- package/package.json +1 -4
- package/publisher.config.example.bigquery.json +7 -7
- package/publisher.config.example.duckdb.json +7 -7
- package/publisher.config.json +7 -11
- package/src/config.spec.ts +2 -2
- package/src/controller/package.controller.ts +62 -31
- package/src/default-publisher.config.json +7 -7
- package/src/health.ts +3 -8
- package/src/mcp/error_messages.ts +8 -37
- package/src/mcp/handler_utils.spec.ts +108 -0
- package/src/mcp/handler_utils.ts +99 -124
- package/src/mcp/mcp_constants.ts +0 -16
- package/src/mcp/server.protocol.spec.ts +138 -0
- package/src/mcp/server.ts +57 -37
- package/src/mcp/skills/build_skills_bundle.ts +1 -1
- package/src/mcp/skills/skills_bundle.json +1 -1
- package/src/mcp/tools/compile_tool.spec.ts +207 -0
- package/src/mcp/tools/compile_tool.ts +177 -0
- package/src/mcp/tools/docs_search_tool.ts +1 -1
- package/src/mcp/tools/execute_query_tool.spec.ts +143 -0
- package/src/mcp/tools/execute_query_tool.ts +39 -6
- package/src/mcp/tools/get_context_eval.ts +3 -3
- package/src/mcp/tools/get_context_tool.spec.ts +196 -1
- package/src/mcp/tools/get_context_tool.ts +165 -67
- package/src/mcp/tools/reload_package_tool.spec.ts +232 -0
- package/src/mcp/tools/reload_package_tool.ts +158 -0
- package/src/package_load/package_load_pool.ts +3 -0
- package/src/package_load/package_load_worker.ts +68 -24
- package/src/package_load/protocol.ts +16 -0
- package/src/package_load/rpc_wait_accountant.spec.ts +109 -0
- package/src/package_load/rpc_wait_accountant.ts +76 -0
- package/src/package_load_metrics.spec.ts +114 -0
- package/src/package_load_metrics.ts +127 -0
- package/src/pg_helpers.spec.ts +2 -206
- package/src/pg_helpers.ts +4 -120
- package/src/runtime/publisher.js +5 -0
- package/src/server.ts +7 -21
- package/src/service/environment.ts +71 -7
- package/src/service/model.spec.ts +92 -0
- package/src/service/model.ts +58 -7
- package/src/service/package.ts +113 -55
- package/src/service/package_reload_safety.spec.ts +193 -0
- package/src/test_helpers/metrics_harness.ts +40 -0
- package/tests/fixtures/query-givens/data/orders.csv +7 -0
- package/tests/fixtures/query-givens/model.malloy +34 -0
- package/tests/fixtures/query-givens/publisher.json +5 -0
- package/tests/harness/mcp_test_setup.ts +1 -1
- package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +22 -22
- package/tests/integration/mcp/mcp_transport.integration.spec.ts +7 -31
- package/tests/integration/query_givens/query_givens.integration.spec.ts +146 -0
- package/tests/integration/query_givens/query_givens_authorize.integration.spec.ts +121 -0
- package/tests/integration/sdk_givens/sdk_givens.integration.spec.ts +110 -0
- package/tests/integration/watch-mode/watch_mode.integration.spec.ts +0 -6
- package/dxt/malloy_bridge.py +0 -354
- package/dxt/manifest.json +0 -22
- package/src/dto/connection.dto.spec.ts +0 -186
- package/src/dto/connection.dto.ts +0 -308
- package/src/dto/index.ts +0 -2
- package/src/dto/package.dto.spec.ts +0 -42
- package/src/dto/package.dto.ts +0 -27
- package/src/dto/validate.spec.ts +0 -76
- package/src/dto/validate.ts +0 -31
- package/src/ducklake_version.spec.ts +0 -43
- package/src/ducklake_version.ts +0 -26
- package/src/mcp/agent_server.protocol.spec.ts +0 -78
- package/src/mcp/agent_server.spec.ts +0 -18
- package/src/mcp/agent_server.ts +0 -144
- package/src/mcp/prompts/handlers.ts +0 -84
- package/src/mcp/prompts/index.ts +0 -11
- package/src/mcp/prompts/prompt_definitions.ts +0 -160
- package/src/mcp/prompts/prompt_service.ts +0 -67
- package/src/mcp/prompts/utils.ts +0 -62
- package/src/mcp/resource_metadata.ts +0 -47
- package/src/mcp/resources/environment_resource.ts +0 -187
- package/src/mcp/resources/model_resource.ts +0 -155
- package/src/mcp/resources/notebook_resource.ts +0 -137
- package/src/mcp/resources/package_resource.ts +0 -373
- package/src/mcp/resources/query_resource.ts +0 -122
- package/src/mcp/resources/source_resource.ts +0 -141
- package/src/mcp/resources/view_resource.ts +0 -136
- package/src/mcp/tools/discovery_tools.ts +0 -280
- package/src/storage/BaseRepository.ts +0 -31
- package/src/storage/StorageManager.mock.ts +0 -50
- package/tests/harness/e2e.ts +0 -96
- package/tests/harness/mocks.ts +0 -39
- package/tests/harness/uris.ts +0 -31
- package/tests/integration/mcp/mcp_resource.integration.spec.ts +0 -655
- package/tests/integration/mcp/setup.spec.ts +0 -5
- package/tests/unit/mcp/prompt_definitions.test.ts +0 -102
- package/tests/unit/mcp/prompt_happy.test.ts +0 -51
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
"frozenConfig": false,
|
|
3
3
|
"environments": [
|
|
4
4
|
{
|
|
5
|
-
"name": "
|
|
5
|
+
"name": "examples",
|
|
6
6
|
"packages": [
|
|
7
7
|
{
|
|
8
|
-
"name": "
|
|
9
|
-
"location": "https://github.com/
|
|
8
|
+
"name": "storefront",
|
|
9
|
+
"location": "https://github.com/malloydata/publisher/tree/main/examples/storefront"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
|
-
"name": "
|
|
13
|
-
"location": "https://github.com/
|
|
12
|
+
"name": "governed-analytics",
|
|
13
|
+
"location": "https://github.com/malloydata/publisher/tree/main/examples/governed-analytics"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
|
-
"name": "
|
|
17
|
-
"location": "https://github.com/
|
|
16
|
+
"name": "html-data-app",
|
|
17
|
+
"location": "https://github.com/malloydata/publisher/tree/main/examples/html-data-app"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
"connections": []
|
|
@@ -12147,6 +12147,47 @@ function errMessage(err) {
|
|
|
12147
12147
|
return err instanceof Error ? err.message : String(err);
|
|
12148
12148
|
}
|
|
12149
12149
|
|
|
12150
|
+
// src/package_load/rpc_wait_accountant.ts
|
|
12151
|
+
class RpcWaitAccountant {
|
|
12152
|
+
now;
|
|
12153
|
+
inFlight = 0;
|
|
12154
|
+
waitStartMs = 0;
|
|
12155
|
+
accumMs = 0;
|
|
12156
|
+
startedCount = 0;
|
|
12157
|
+
activeJobId;
|
|
12158
|
+
constructor(now = () => performance.now()) {
|
|
12159
|
+
this.now = now;
|
|
12160
|
+
}
|
|
12161
|
+
begin(jobId) {
|
|
12162
|
+
this.activeJobId = jobId;
|
|
12163
|
+
this.inFlight = 0;
|
|
12164
|
+
this.waitStartMs = 0;
|
|
12165
|
+
this.accumMs = 0;
|
|
12166
|
+
this.startedCount = 0;
|
|
12167
|
+
}
|
|
12168
|
+
noteStart(jobId) {
|
|
12169
|
+
if (jobId !== this.activeJobId)
|
|
12170
|
+
return;
|
|
12171
|
+
if (this.inFlight === 0)
|
|
12172
|
+
this.waitStartMs = this.now();
|
|
12173
|
+
this.inFlight += 1;
|
|
12174
|
+
this.startedCount += 1;
|
|
12175
|
+
}
|
|
12176
|
+
noteSettle(jobId) {
|
|
12177
|
+
if (jobId !== this.activeJobId)
|
|
12178
|
+
return;
|
|
12179
|
+
this.inFlight -= 1;
|
|
12180
|
+
if (this.inFlight === 0)
|
|
12181
|
+
this.accumMs += this.now() - this.waitStartMs;
|
|
12182
|
+
}
|
|
12183
|
+
get waitMs() {
|
|
12184
|
+
return this.accumMs;
|
|
12185
|
+
}
|
|
12186
|
+
get fetches() {
|
|
12187
|
+
return this.startedCount;
|
|
12188
|
+
}
|
|
12189
|
+
}
|
|
12190
|
+
|
|
12150
12191
|
// src/package_load/package_load_worker.ts
|
|
12151
12192
|
if (!parentPort) {
|
|
12152
12193
|
throw new Error("package_load_worker.ts must be loaded inside a worker_threads Worker");
|
|
@@ -12168,6 +12209,7 @@ function callMain(send) {
|
|
|
12168
12209
|
send(requestId);
|
|
12169
12210
|
});
|
|
12170
12211
|
}
|
|
12212
|
+
var schemaWait = new RpcWaitAccountant;
|
|
12171
12213
|
function dispatchMainResponse(message) {
|
|
12172
12214
|
if (message.type === "schema-for-tables-response" || message.type === "schema-for-sql-response" || message.type === "read-url-response" || message.type === "connection-metadata-response") {
|
|
12173
12215
|
const pending = pendingRpc.get(message.requestId);
|
|
@@ -12202,31 +12244,42 @@ class ProxyConnection {
|
|
|
12202
12244
|
return this.digest;
|
|
12203
12245
|
}
|
|
12204
12246
|
async fetchSchemaForTables(tables, options) {
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12247
|
+
schemaWait.noteStart(this.jobId);
|
|
12248
|
+
try {
|
|
12249
|
+
const response = await callMain((requestId) => {
|
|
12250
|
+
const req = {
|
|
12251
|
+
type: "schema-for-tables",
|
|
12252
|
+
requestId,
|
|
12253
|
+
jobId: this.jobId,
|
|
12254
|
+
connectionName: this.name,
|
|
12255
|
+
tables,
|
|
12256
|
+
options: serializeFetchOptions(options)
|
|
12257
|
+
};
|
|
12258
|
+
port.postMessage(req);
|
|
12259
|
+
});
|
|
12260
|
+
return { schemas: response.schemas, errors: response.errors };
|
|
12261
|
+
} finally {
|
|
12262
|
+
schemaWait.noteSettle(this.jobId);
|
|
12263
|
+
}
|
|
12217
12264
|
}
|
|
12218
12265
|
async fetchSchemaForSQLStruct(sentence, options) {
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12224
|
-
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12266
|
+
schemaWait.noteStart(this.jobId);
|
|
12267
|
+
let response;
|
|
12268
|
+
try {
|
|
12269
|
+
response = await callMain((requestId) => {
|
|
12270
|
+
const req = {
|
|
12271
|
+
type: "schema-for-sql",
|
|
12272
|
+
requestId,
|
|
12273
|
+
jobId: this.jobId,
|
|
12274
|
+
connectionName: this.name,
|
|
12275
|
+
sentence,
|
|
12276
|
+
options: serializeFetchOptions(options)
|
|
12277
|
+
};
|
|
12278
|
+
port.postMessage(req);
|
|
12279
|
+
});
|
|
12280
|
+
} finally {
|
|
12281
|
+
schemaWait.noteSettle(this.jobId);
|
|
12282
|
+
}
|
|
12230
12283
|
if (response.error !== undefined)
|
|
12231
12284
|
return { error: response.error };
|
|
12232
12285
|
if (response.structDef === undefined) {
|
|
@@ -12559,13 +12612,22 @@ async function loadPackage(job) {
|
|
|
12559
12612
|
const malloyConfig = buildWorkerMalloyConfig(job);
|
|
12560
12613
|
const allFiles = await listPackageFiles(job.packagePath);
|
|
12561
12614
|
const modelPaths = filterModelPaths(allFiles);
|
|
12615
|
+
const compileRegionStart = performance.now();
|
|
12616
|
+
schemaWait.begin(job.requestId);
|
|
12562
12617
|
const models = await Promise.all(modelPaths.map((modelPath) => compileOneModel(job, malloyConfig, modelPath)));
|
|
12618
|
+
const loadEnd = performance.now();
|
|
12619
|
+
const schemaFetchDurationMs = schemaWait.waitMs;
|
|
12563
12620
|
return {
|
|
12564
12621
|
type: "load-package-result",
|
|
12565
12622
|
requestId: job.requestId,
|
|
12566
12623
|
packageMetadata,
|
|
12567
12624
|
models,
|
|
12568
|
-
loadDurationMs:
|
|
12625
|
+
loadDurationMs: loadEnd - loadStart,
|
|
12626
|
+
timings: {
|
|
12627
|
+
compileDurationMs: Math.max(0, loadEnd - compileRegionStart - schemaFetchDurationMs),
|
|
12628
|
+
schemaFetchDurationMs,
|
|
12629
|
+
schemaFetchCount: schemaWait.fetches
|
|
12630
|
+
}
|
|
12569
12631
|
};
|
|
12570
12632
|
}
|
|
12571
12633
|
function serializeError(error) {
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
// Exposes window.Publisher with:
|
|
6
6
|
// - Publisher.query(model, malloy, opts?) → Promise<rows[]>
|
|
7
7
|
// - Publisher.queryFull(model, malloy, opts?) → Promise<MalloyResult> (envelope for <malloy-render>)
|
|
8
|
+
// opts: { environment?, package?, sourceName?, queryName?, filterParams?,
|
|
9
|
+
// bypassFilters?, givens? }. givens is a name→value map bound as
|
|
10
|
+
// Malloy given: runtime parameters for this query (safe parameterization,
|
|
11
|
+
// not string interpolation) — see the malloy-html-data-app-runtime skill.
|
|
8
12
|
// - Publisher.embed(selector, { src, height?, token? })
|
|
9
13
|
// - Publisher.context ({ environment, package } inferred from URL)
|
|
10
14
|
// - Publisher.setToken(token) (override Bearer token; default uses cookies)
|
|
@@ -92,6 +96,7 @@
|
|
|
92
96
|
if (opts.queryName) body.queryName = opts.queryName;
|
|
93
97
|
if (opts.filterParams) body.filterParams = opts.filterParams;
|
|
94
98
|
if (opts.bypassFilters) body.bypassFilters = true;
|
|
99
|
+
if (opts.givens) body.givens = opts.givens;
|
|
95
100
|
|
|
96
101
|
var headers = Object.assign(
|
|
97
102
|
{ "content-type": "application/json" },
|