@malloy-publisher/server 0.0.204 → 0.0.206
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 +10 -1
- package/dist/app/api-doc.yaml +494 -397
- package/dist/app/assets/{EnvironmentPage-CX06cjOF.js → EnvironmentPage-BYwBeC2F.js} +1 -1
- package/dist/app/assets/HomePage-ivu4vdpj.js +1 -0
- package/dist/app/assets/{MainPage-nUJ9YatG.js → MainPage-B2DnHEDU.js} +2 -2
- package/dist/app/assets/MaterializationsPage-BZEuwF9P.js +1 -0
- package/dist/app/assets/ModelPage-Dpu3bfPg.js +1 -0
- package/dist/app/assets/{PackagePage-BaEVdEAG.js → PackagePage-B8PwcRHt.js} +1 -1
- package/dist/app/assets/{RouteError-BShQjZio.js → RouteError-BhbywAeC.js} +1 -1
- package/dist/app/assets/{WorkbookPage-CBn6ZjJW.js → WorkbookPage-C-JXsJG0.js} +1 -1
- package/dist/app/assets/{core-DECXYL4E.es-OaRfXwuQ.js → core-pPlPr7jK.es-CNEOlxKB.js} +1 -1
- package/dist/app/assets/{index-BLfPC1gy.js → index-BHEm8Egc.js} +1 -1
- package/dist/app/assets/{index-Dy3YhAZQ.js → index-BsvDrV14.js} +1 -1
- package/dist/app/assets/{index-DqiJ0bWp.js → index-ChR1fKR2.js} +134 -134
- package/dist/app/assets/{index.umd-DAN9K8yC.js → index.umd-BVLPYNuj.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/instrumentation.mjs +18 -8
- package/dist/package_load_worker.mjs +19 -2
- package/dist/runtime/publisher.js +318 -0
- package/dist/server.mjs +1703 -1443
- package/package.json +5 -4
- package/scripts/bake-duckdb-extensions.js +104 -0
- package/src/constants.ts +12 -0
- package/src/controller/materialization.controller.ts +79 -35
- package/src/controller/package.controller.spec.ts +179 -0
- package/src/controller/package.controller.ts +60 -73
- package/src/controller/watch-mode.controller.ts +176 -46
- package/src/dto/package.dto.ts +16 -1
- package/src/errors.spec.ts +33 -0
- package/src/errors.ts +18 -0
- package/src/health.spec.ts +34 -1
- package/src/instrumentation.ts +33 -17
- package/src/materialization_metrics.ts +66 -0
- package/src/mcp/error_messages.spec.ts +35 -0
- package/src/mcp/error_messages.ts +14 -1
- package/src/mcp/handler_utils.ts +12 -0
- package/src/package_load/package_load_pool.ts +7 -1
- package/src/package_load/package_load_worker.ts +44 -4
- package/src/package_load/protocol.ts +7 -1
- package/src/runtime/publisher.js +318 -0
- package/src/server-old.ts +7 -149
- package/src/server.ts +488 -190
- package/src/service/authorize_integration.spec.ts +163 -2
- package/src/service/compile_authorize.spec.ts +85 -0
- package/src/service/environment.ts +270 -12
- package/src/service/environment_store.spec.ts +0 -81
- package/src/service/environment_store.ts +142 -34
- package/src/service/explore_visibility.spec.ts +434 -0
- package/src/service/exports_probe.spec.ts +107 -0
- package/src/service/manifest_loader.spec.ts +99 -0
- package/src/service/manifest_loader.ts +95 -0
- package/src/service/materialization_service.spec.ts +324 -512
- package/src/service/materialization_service.ts +816 -656
- package/src/service/model.ts +444 -13
- package/src/service/package.spec.ts +14 -2
- package/src/service/package.ts +271 -20
- package/src/service/package_rollback.spec.ts +190 -0
- package/src/service/package_worker_path.spec.ts +223 -0
- package/src/service/query_boundary.spec.ts +470 -0
- package/src/storage/DatabaseInterface.ts +35 -57
- package/src/storage/StorageManager.mock.ts +0 -9
- package/src/storage/StorageManager.ts +7 -290
- package/src/storage/duckdb/DuckDBConnection.ts +70 -124
- package/src/storage/duckdb/DuckDBRepository.ts +2 -35
- package/src/storage/duckdb/MaterializationRepository.ts +52 -27
- package/src/storage/duckdb/schema.ts +4 -20
- package/tests/fixtures/authorize-compile/model.malloy +9 -0
- package/tests/fixtures/authorize-compile/publisher.json +4 -0
- package/tests/fixtures/html-pages-nopublic/model.malloy +1 -0
- package/tests/fixtures/html-pages-nopublic/publisher.json +5 -0
- package/tests/fixtures/html-pages-test/data.csv +3 -0
- package/tests/fixtures/html-pages-test/public/assets/app.css +3 -0
- package/tests/fixtures/html-pages-test/public/data.json +1 -0
- package/tests/fixtures/html-pages-test/public/index.html +9 -0
- package/tests/fixtures/html-pages-test/public/sub/page2.html +9 -0
- package/tests/fixtures/html-pages-test/publisher.json +5 -0
- package/tests/fixtures/html-pages-test/report.malloy +1 -0
- package/tests/integration/authorize/compile_authorize_http.integration.spec.ts +92 -0
- package/tests/integration/duckdb_storage/duckdb_storage.integration.spec.ts +138 -0
- package/tests/integration/html_pages/html_pages.integration.spec.ts +378 -0
- package/tests/integration/materialization/manifest_binding.integration.spec.ts +175 -0
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +277 -266
- package/tests/integration/watch-mode/watch_mode.integration.spec.ts +421 -0
- package/tests/unit/duckdb/attached_databases.test.ts +111 -0
- package/tests/unit/duckdb/duckdb_connection.test.ts +181 -0
- package/tests/unit/duckdb/legacy_schema_migration.test.ts +7 -4
- package/tests/unit/duckdb/repositories.test.ts +208 -0
- package/dist/app/assets/HomePage-CNFt_eUU.js +0 -1
- package/dist/app/assets/MaterializationsPage-B5goxVXW.js +0 -1
- package/dist/app/assets/ModelPage-Ba7Xh4lL.js +0 -1
- package/src/controller/manifest.controller.ts +0 -38
- package/src/service/manifest_service.spec.ts +0 -206
- package/src/service/manifest_service.ts +0 -117
- package/src/service/materialized_table_gc.spec.ts +0 -384
- package/src/service/materialized_table_gc.ts +0 -231
- package/src/storage/duckdb/DuckDBManifestStore.ts +0 -70
- package/src/storage/duckdb/ManifestRepository.ts +0 -120
- package/src/storage/duckdb/manifest_store.spec.ts +0 -133
- package/src/storage/ducklake/DuckLakeManifestStore.ts +0 -155
- package/tests/unit/storage/StorageManager.test.ts +0 -166
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { GetObjectCommand, S3 } from "@aws-sdk/client-s3";
|
|
2
|
+
import { Storage } from "@google-cloud/storage";
|
|
3
|
+
import * as fs from "fs/promises";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { components } from "../api";
|
|
6
|
+
import { logger } from "../logger";
|
|
7
|
+
import { BuildManifest } from "../storage/DatabaseInterface";
|
|
8
|
+
|
|
9
|
+
type WireBuildManifest = components["schemas"]["BuildManifest"];
|
|
10
|
+
|
|
11
|
+
// Lazily-created clients reused across fetches. Both use the ambient credential
|
|
12
|
+
// chain (ADC for GCS; the default provider chain for S3) — the same auth the
|
|
13
|
+
// package downloader already relies on.
|
|
14
|
+
let gcsClient: Storage | undefined;
|
|
15
|
+
let s3Client: S3 | undefined;
|
|
16
|
+
|
|
17
|
+
function parseBucketUri(
|
|
18
|
+
uri: string,
|
|
19
|
+
scheme: "gs://" | "s3://",
|
|
20
|
+
): { bucket: string; key: string } {
|
|
21
|
+
const rest = uri.slice(scheme.length);
|
|
22
|
+
const slash = rest.indexOf("/");
|
|
23
|
+
if (slash <= 0 || slash === rest.length - 1) {
|
|
24
|
+
throw new Error(`Malformed manifest URI: ${uri}`);
|
|
25
|
+
}
|
|
26
|
+
return { bucket: rest.slice(0, slash), key: rest.slice(slash + 1) };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Read the raw bytes of a manifest URI (gs://, s3://, file://, or local path). */
|
|
30
|
+
async function readManifestBytes(uri: string): Promise<string> {
|
|
31
|
+
if (uri.startsWith("gs://")) {
|
|
32
|
+
const { bucket, key } = parseBucketUri(uri, "gs://");
|
|
33
|
+
gcsClient ??= new Storage();
|
|
34
|
+
const [contents] = await gcsClient.bucket(bucket).file(key).download();
|
|
35
|
+
return contents.toString("utf8");
|
|
36
|
+
}
|
|
37
|
+
if (uri.startsWith("s3://")) {
|
|
38
|
+
const { bucket, key } = parseBucketUri(uri, "s3://");
|
|
39
|
+
s3Client ??= new S3({ followRegionRedirects: true });
|
|
40
|
+
const res = await s3Client.send(
|
|
41
|
+
new GetObjectCommand({ Bucket: bucket, Key: key }),
|
|
42
|
+
);
|
|
43
|
+
if (!res.Body) {
|
|
44
|
+
throw new Error(`Empty S3 response for manifest URI: ${uri}`);
|
|
45
|
+
}
|
|
46
|
+
return res.Body.transformToString();
|
|
47
|
+
}
|
|
48
|
+
if (uri.startsWith("file://")) {
|
|
49
|
+
return fs.readFile(fileURLToPath(uri), "utf8");
|
|
50
|
+
}
|
|
51
|
+
// Bare local path (used by tests and local/mounted deployments). The URI is
|
|
52
|
+
// operator-supplied config (publisher.json or an authenticated PATCH), not
|
|
53
|
+
// end-user input, and the file's contents are never returned to the caller —
|
|
54
|
+
// only physicalTableName strings are extracted — so the CodeQL
|
|
55
|
+
// js/path-injection alert here is a dismissed false positive.
|
|
56
|
+
return fs.readFile(uri, "utf8");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Fetch and parse the control-plane-computed build manifest at `uri`, returning
|
|
61
|
+
* the Malloy-runtime binding map (`buildId -> { tableName }`). The wire manifest
|
|
62
|
+
* keys physical tables under `physicalTableName`; the Malloy runtime consumes
|
|
63
|
+
* `tableName`, so we translate here. Entries missing a physical table are
|
|
64
|
+
* skipped. Throws if the URI can't be read or parsed.
|
|
65
|
+
*/
|
|
66
|
+
export async function fetchManifestEntries(
|
|
67
|
+
uri: string,
|
|
68
|
+
): Promise<BuildManifest["entries"]> {
|
|
69
|
+
const raw = await readManifestBytes(uri);
|
|
70
|
+
|
|
71
|
+
let parsed: WireBuildManifest;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(raw) as WireBuildManifest;
|
|
74
|
+
} catch (err) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Failed to parse build manifest at ${uri}: ${
|
|
77
|
+
err instanceof Error ? err.message : String(err)
|
|
78
|
+
}`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const entries: BuildManifest["entries"] = {};
|
|
83
|
+
for (const [buildId, entry] of Object.entries(parsed.entries ?? {})) {
|
|
84
|
+
const physicalTableName = entry?.physicalTableName;
|
|
85
|
+
if (!physicalTableName) {
|
|
86
|
+
logger.warn("Manifest entry has no physicalTableName; skipping", {
|
|
87
|
+
uri,
|
|
88
|
+
buildId,
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
entries[buildId] = { tableName: physicalTableName };
|
|
93
|
+
}
|
|
94
|
+
return entries;
|
|
95
|
+
}
|