@malloy-publisher/server 0.0.205 → 0.0.207
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/dist/app/api-doc.yaml +394 -395
- package/dist/app/assets/{EnvironmentPage-CAge6UHD.js → EnvironmentPage-BScgHmkw.js} +1 -1
- package/dist/app/assets/{HomePage-DhTe8qpa.js → HomePage-CGedji_w.js} +1 -1
- package/dist/app/assets/{MainPage-CeTxxGex.js → MainPage-DWfF4jXW.js} +2 -2
- package/dist/app/assets/{MaterializationsPage-CpDHB70t.js → MaterializationsPage-B9PDlk8c.js} +1 -1
- package/dist/app/assets/{ModelPage-D9sSMb75.js → ModelPage-BiNOgK_e.js} +1 -1
- package/dist/app/assets/{PackagePage-LRqQWrFY.js → PackagePage-DAN5V7gu.js} +1 -1
- package/dist/app/assets/{RouteError-xT6kuCNw.js → RouteError-CEnIzuKN.js} +1 -1
- package/dist/app/assets/{WorkbookPage-DsIh9svZ.js → WorkbookPage-gA1ceqHP.js} +1 -1
- package/dist/app/assets/{core-C2sQrwVu.es-Bjem0hym.js → core-AOmIKwkc.es-Dclu1Fga.js} +1 -1
- package/dist/app/assets/{index-BdOZDcce.js → index-DGGe8UpP.js} +1 -1
- package/dist/app/assets/{index-RX3QOTde.js → index-DtlPzNxc.js} +127 -127
- package/dist/app/assets/{index-DHHAcY5o.js → index-uu6UpHd2.js} +1 -1
- package/dist/app/assets/{index.umd-D2WH3D-f.js → index.umd-DDq93YX4.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/server.mjs +1272 -1299
- package/package.json +1 -1
- 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/dto/package.dto.ts +16 -1
- package/src/errors.spec.ts +12 -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 +121 -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/server-old.ts +7 -149
- package/src/server.ts +9 -188
- package/src/service/authorize_integration.spec.ts +67 -0
- package/src/service/environment.ts +270 -12
- package/src/service/environment_store.spec.ts +0 -81
- package/src/service/environment_store.ts +0 -23
- 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 +584 -500
- package/src/service/materialization_service.ts +839 -657
- package/src/service/model.ts +419 -15
- package/src/service/package.spec.ts +14 -2
- package/src/service/package.ts +339 -29
- 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/DuckDBRepository.ts +2 -35
- package/src/storage/duckdb/MaterializationRepository.ts +52 -27
- package/src/storage/duckdb/schema.ts +4 -20
- package/tests/integration/materialization/manifest_binding.integration.spec.ts +194 -0
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +369 -264
- package/tests/unit/duckdb/legacy_schema_migration.test.ts +7 -4
- 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,194 @@
|
|
|
1
|
+
/// <reference types="bun-types" />
|
|
2
|
+
|
|
3
|
+
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
|
|
4
|
+
import * as fsp from "fs/promises";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { RestE2EEnv, startRestE2E } from "../../harness/rest_e2e";
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
|
|
13
|
+
const PROJECT_NAME = "manifest-bind-project";
|
|
14
|
+
const PACKAGE_NAME = "persist-test";
|
|
15
|
+
const MODEL_PATH = "persist_test.malloy";
|
|
16
|
+
const API = `/api/v0/environments/${PROJECT_NAME}/packages/${PACKAGE_NAME}`;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Covers the publisher's manifestLocation plumbing: create/update accepts a
|
|
20
|
+
* manifest URI, it is persisted to publisher.json (so it survives a reload),
|
|
21
|
+
* the package loader fetches + binds it through the existing reloadAllModels
|
|
22
|
+
* primitive on every (re)load, an unreachable manifest degrades to serving
|
|
23
|
+
* live, and clearing it reverts.
|
|
24
|
+
*
|
|
25
|
+
* The build-time rewrite of upstream persist references to physical tables is
|
|
26
|
+
* Malloy's reloadAllModels behavior, exercised by the materialization lifecycle
|
|
27
|
+
* spec; here we assert the publisher-owned fetch/persist/bind wiring.
|
|
28
|
+
*/
|
|
29
|
+
describe("Manifest binding via Package.manifestLocation (E2E)", () => {
|
|
30
|
+
let env: (RestE2EEnv & { stop(): Promise<void> }) | null = null;
|
|
31
|
+
let baseUrl: string;
|
|
32
|
+
let tmpDir: string;
|
|
33
|
+
|
|
34
|
+
beforeAll(async () => {
|
|
35
|
+
env = await startRestE2E();
|
|
36
|
+
baseUrl = env.baseUrl;
|
|
37
|
+
tmpDir = await fsp.mkdtemp(path.join(os.tmpdir(), "manifest-bind-"));
|
|
38
|
+
|
|
39
|
+
const fixtureDir = path.resolve(__dirname, "../../fixtures/persist-test");
|
|
40
|
+
const createRes = await fetch(`${baseUrl}/api/v0/environments`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: { "Content-Type": "application/json" },
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
name: PROJECT_NAME,
|
|
45
|
+
packages: [{ name: PACKAGE_NAME, location: fixtureDir }],
|
|
46
|
+
connections: [],
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
if (!createRes.ok) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`Failed to create test project (${createRes.status}): ${await createRes.text()}`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const deadline = Date.now() + 30_000;
|
|
56
|
+
while (Date.now() < deadline) {
|
|
57
|
+
const res = await fetch(`${baseUrl}${API}`);
|
|
58
|
+
if (res.ok) break;
|
|
59
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
afterAll(async () => {
|
|
64
|
+
if (baseUrl) {
|
|
65
|
+
await fetch(`${baseUrl}/api/v0/environments/${PROJECT_NAME}`, {
|
|
66
|
+
method: "DELETE",
|
|
67
|
+
}).catch(() => {});
|
|
68
|
+
}
|
|
69
|
+
await env?.stop();
|
|
70
|
+
await fsp.rm(tmpDir, { recursive: true, force: true }).catch(() => {});
|
|
71
|
+
env = null;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
function url(p: string): string {
|
|
75
|
+
return `${baseUrl}${API}${p}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function getPackage(reload = false): Promise<Record<string, unknown>> {
|
|
79
|
+
const res = await fetch(url(reload ? "?reload=true" : ""));
|
|
80
|
+
expect(res.status).toBe(200);
|
|
81
|
+
return (await res.json()) as Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function patchPackage(
|
|
85
|
+
body: Record<string, unknown>,
|
|
86
|
+
): Promise<Response> {
|
|
87
|
+
return fetch(url(""), {
|
|
88
|
+
method: "PATCH",
|
|
89
|
+
headers: { "Content-Type": "application/json" },
|
|
90
|
+
body: JSON.stringify({ name: PACKAGE_NAME, ...body }),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function queryOrderSummaryStatus(): Promise<number> {
|
|
95
|
+
const res = await fetch(`${baseUrl}${API}/models/${MODEL_PATH}/query`, {
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: { "Content-Type": "application/json" },
|
|
98
|
+
body: JSON.stringify({
|
|
99
|
+
query: "run: order_summary -> { aggregate: c is count() }",
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
return res.status;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function writeManifest(): Promise<string> {
|
|
106
|
+
const file = path.join(tmpDir, `manifest-${Date.now()}.json`);
|
|
107
|
+
await fsp.writeFile(
|
|
108
|
+
file,
|
|
109
|
+
JSON.stringify({
|
|
110
|
+
builtAt: new Date().toISOString(),
|
|
111
|
+
strict: false,
|
|
112
|
+
entries: {
|
|
113
|
+
build123: {
|
|
114
|
+
buildId: "build123",
|
|
115
|
+
sourceName: "order_summary",
|
|
116
|
+
physicalTableName: "main.order_summary_mz",
|
|
117
|
+
connectionName: "duckdb",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
"utf8",
|
|
122
|
+
);
|
|
123
|
+
return file;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
it("starts with no manifestLocation and serves live", async () => {
|
|
127
|
+
expect((await getPackage()).manifestLocation ?? null).toBeNull();
|
|
128
|
+
expect(await queryOrderSummaryStatus()).toBe(200);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it(
|
|
132
|
+
"accepts, persists, reloads, and clears a manifestLocation",
|
|
133
|
+
async () => {
|
|
134
|
+
const manifestFile = await writeManifest();
|
|
135
|
+
|
|
136
|
+
// Accept on update; the response echoes the bound location and the
|
|
137
|
+
// server-computed binding observability fields (surfaced on /status so
|
|
138
|
+
// the control plane can confirm the worker actually bound the manifest).
|
|
139
|
+
const patchRes = await patchPackage({
|
|
140
|
+
manifestLocation: manifestFile,
|
|
141
|
+
});
|
|
142
|
+
expect(patchRes.status).toBe(200);
|
|
143
|
+
const patched = await patchRes.json();
|
|
144
|
+
expect(patched.manifestLocation).toBe(manifestFile);
|
|
145
|
+
expect(patched.manifestBindingStatus).toBe("bound");
|
|
146
|
+
expect(patched.manifestEntryCount).toBe(1);
|
|
147
|
+
expect(patched.boundManifestUri).toBe(manifestFile);
|
|
148
|
+
|
|
149
|
+
// In-memory metadata reflects it; binding did not break serving.
|
|
150
|
+
const bound = await getPackage();
|
|
151
|
+
expect(bound.manifestLocation).toBe(manifestFile);
|
|
152
|
+
expect(bound.manifestBindingStatus).toBe("bound");
|
|
153
|
+
expect(bound.manifestEntryCount).toBe(1);
|
|
154
|
+
expect(await queryOrderSummaryStatus()).toBe(200);
|
|
155
|
+
|
|
156
|
+
// Persisted to publisher.json: a reload re-reads and re-binds it.
|
|
157
|
+
expect((await getPackage(true)).manifestLocation).toBe(manifestFile);
|
|
158
|
+
expect(await queryOrderSummaryStatus()).toBe(200);
|
|
159
|
+
|
|
160
|
+
// Clearing reverts to live (unbound) and survives a reload.
|
|
161
|
+
const clearRes = await patchPackage({ manifestLocation: null });
|
|
162
|
+
expect(clearRes.status).toBe(200);
|
|
163
|
+
const cleared = await clearRes.json();
|
|
164
|
+
expect(cleared.manifestLocation ?? null).toBeNull();
|
|
165
|
+
expect(cleared.manifestBindingStatus).toBe("unbound");
|
|
166
|
+
expect(cleared.manifestEntryCount).toBe(0);
|
|
167
|
+
expect(cleared.boundManifestUri ?? null).toBeNull();
|
|
168
|
+
expect((await getPackage(true)).manifestLocation ?? null).toBeNull();
|
|
169
|
+
expect(await queryOrderSummaryStatus()).toBe(200);
|
|
170
|
+
},
|
|
171
|
+
{ timeout: 60_000 },
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
it("degrades to serving live when the manifest is unreachable", async () => {
|
|
175
|
+
const missing = path.join(tmpDir, "does-not-exist.json");
|
|
176
|
+
|
|
177
|
+
const patchRes = await patchPackage({ manifestLocation: missing });
|
|
178
|
+
expect(patchRes.status).toBe(200);
|
|
179
|
+
const patched = await patchRes.json();
|
|
180
|
+
expect(patched.manifestLocation).toBe(missing);
|
|
181
|
+
// The configured location is retained, but the binding is reported as a
|
|
182
|
+
// degraded live fallback (not "bound") with nothing actually bound.
|
|
183
|
+
expect(patched.manifestBindingStatus).toBe("live_fallback");
|
|
184
|
+
expect(patched.manifestEntryCount).toBe(0);
|
|
185
|
+
expect(patched.boundManifestUri ?? null).toBeNull();
|
|
186
|
+
|
|
187
|
+
// A fetch failure must not brick the package — it still serves live.
|
|
188
|
+
expect(await queryOrderSummaryStatus()).toBe(200);
|
|
189
|
+
expect((await getPackage(true)).manifestLocation).toBe(missing);
|
|
190
|
+
expect(await queryOrderSummaryStatus()).toBe(200);
|
|
191
|
+
|
|
192
|
+
await patchPackage({ manifestLocation: null });
|
|
193
|
+
});
|
|
194
|
+
});
|