@dbt-tools/web 0.6.1 → 0.6.4
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.md +28 -25
- package/dist/assets/{analysis.worker-BzrXut-o.js → analysis.worker-43rj6paY.js} +1 -1
- package/dist/assets/index-CQwlMVeT.js +36 -0
- package/dist/favicon.svg +11 -0
- package/dist/index.html +2 -2
- package/dist-serve/favicon.svg +11 -0
- package/dist-serve/server/cli.js +268 -78
- package/package.json +3 -3
- package/dist/assets/app-logo-ByfNNtT8.svg +0 -30
- package/dist/assets/index-WFlxSrs-.js +0 -36
package/dist/favicon.svg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Canonical: keep in sync with docs/site/public/favicon.svg -->
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="dbt-tools">
|
|
3
|
+
<rect width="64" height="64" rx="12" fill="#000000" />
|
|
4
|
+
<g transform="translate(4 8.375) scale(0.0875)">
|
|
5
|
+
<rect x="108" y="34" width="270" height="68" rx="34" fill="#635BFF" />
|
|
6
|
+
<rect x="276" y="142" width="318" height="68" rx="34" fill="#635BFF" />
|
|
7
|
+
<rect x="24" y="246" width="430" height="72" rx="36" fill="#635BFF" />
|
|
8
|
+
<rect x="220" y="352" width="292" height="68" rx="34" fill="#635BFF" />
|
|
9
|
+
<rect x="108" y="458" width="236" height="68" rx="34" fill="#635BFF" />
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
package/dist/index.html
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>dbt-tools</title>
|
|
7
|
-
<link rel="icon" type="image/svg+xml" href="/
|
|
7
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
9
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
10
10
|
<link
|
|
11
11
|
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap"
|
|
12
12
|
rel="stylesheet"
|
|
13
13
|
/>
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-CQwlMVeT.js"></script>
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-Dw2cE7zH.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/react-vendor-DBiqvVPF.js">
|
|
17
17
|
<link rel="modulepreload" crossorigin href="/assets/tanstack-virtual-vendor-BfMyFx37.js">
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Canonical: keep in sync with docs/site/public/favicon.svg -->
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="dbt-tools">
|
|
3
|
+
<rect width="64" height="64" rx="12" fill="#000000" />
|
|
4
|
+
<g transform="translate(4 8.375) scale(0.0875)">
|
|
5
|
+
<rect x="108" y="34" width="270" height="68" rx="34" fill="#635BFF" />
|
|
6
|
+
<rect x="276" y="142" width="318" height="68" rx="34" fill="#635BFF" />
|
|
7
|
+
<rect x="24" y="246" width="430" height="72" rx="36" fill="#635BFF" />
|
|
8
|
+
<rect x="220" y="352" width="292" height="68" rx="34" fill="#635BFF" />
|
|
9
|
+
<rect x="108" y="458" width="236" height="68" rx="34" fill="#635BFF" />
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
package/dist-serve/server/cli.js
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { ARTIFACT_RUN_ID_CURRENT, DBT_CATALOG_JSON, DBT_MANIFEST_JSON, DBT_RUN_RESULTS_JSON, DBT_SOURCES_JSON, applyEntrypointRemoteOptionsToEnv, argvElementAt, captureSessionBinding, createReadStreamValidated, discoverArtifactCandidates, discoverLocalArtifactRunPaths, entrypointRemoteHelpLines, existsValidated, getDbtToolsDbtTargetFromEnv, getDbtToolsRemoteClientEnvFromEnv, getDbtToolsTargetDirFromEnv, getObjectProperty, isDbtToolsDebugEnabled, isSessionBindingCurrent, joinObjectStorageKey, mergeRemoteSourceConfigWithParsedLocation, normalizeArtifactPrefix, normalizeArtifactPrefix as normalizeArtifactPrefix$1, parseArtifactSourceLocation, parseDbtToolsArtifactTarget, parseEntrypointRemoteArgv, readValidatedUtf8, readValidatedUtf8Sync, realpathValidatedSync, remoteKeysToListedArtifacts, resolveEntrypointRemoteOptions, statValidatedSync } from "@dbt-tools/core";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
2
4
|
import http from "node:http";
|
|
3
5
|
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { ARTIFACT_RUN_ID_CURRENT, DBT_CATALOG_JSON, DBT_MANIFEST_JSON, DBT_RUN_RESULTS_JSON, DBT_SOURCES_JSON, createReadStreamValidated, discoverArtifactCandidates, discoverLocalArtifactRunPaths, existsValidated, getDbtToolsRemoteClientEnvFromEnv, getDbtToolsTargetDirFromEnv, getObjectProperty, isDbtToolsDebugEnabled, joinObjectStorageKey, mergeRemoteSourceConfigWithParsedLocation, normalizeArtifactPrefix, normalizeArtifactPrefix as normalizeArtifactPrefix$1, parseArtifactSourceLocation, readValidatedUtf8, realpathValidatedSync, remoteKeysToListedArtifacts, statValidatedSync } from "@dbt-tools/core";
|
|
6
6
|
import { createRemoteObjectStoreClient } from "@dbt-tools/core/artifact-io";
|
|
7
|
+
//#region src/server/package-version.ts
|
|
8
|
+
/**
|
|
9
|
+
* Resolved at runtime from compiled `dist/*.js` (package root is `..`).
|
|
10
|
+
*/
|
|
11
|
+
function readWebPackageVersion() {
|
|
12
|
+
const pkgPath = fileURLToPath(new URL("../../package.json", import.meta.url));
|
|
13
|
+
const parsed = JSON.parse(readValidatedUtf8Sync(pkgPath));
|
|
14
|
+
if (typeof parsed.version !== "string" || parsed.version.trim() === "") throw new Error("Invalid or missing \"version\" in @dbt-tools/web package.json");
|
|
15
|
+
return parsed.version;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
7
18
|
//#region src/server/cli-args.ts
|
|
8
19
|
/** Pure CLI argument parsing for `dbt-tools-web` (testable without starting the server). */
|
|
9
|
-
var USAGE =
|
|
10
|
-
Usage: dbt-tools-web [options]
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
--
|
|
15
|
-
|
|
20
|
+
var USAGE = [
|
|
21
|
+
"Usage: dbt-tools-web [options]",
|
|
22
|
+
"",
|
|
23
|
+
"Options (CLI flags override env when both are set):",
|
|
24
|
+
...entrypointRemoteHelpLines(),
|
|
25
|
+
" --target <dir> Alias for local --dbt-target (sets DBT_TOOLS_TARGET_DIR)",
|
|
26
|
+
" --port <n> Port to listen on (default: 3000)",
|
|
27
|
+
" -V, --version Print package version",
|
|
28
|
+
" -h, --help Show this help"
|
|
29
|
+
].join("\n");
|
|
30
|
+
var ENTRYPOINT_VALUE_FLAGS = new Set([
|
|
31
|
+
"--dbt-target",
|
|
32
|
+
"--gcs-project-id",
|
|
33
|
+
"--gcs-impersonate-service-account",
|
|
34
|
+
"--s3-region",
|
|
35
|
+
"--s3-endpoint"
|
|
36
|
+
]);
|
|
16
37
|
function readRequiredValue(argv, i, flagDesc) {
|
|
17
|
-
const next = argv
|
|
38
|
+
const next = argvElementAt(argv, i + 1);
|
|
18
39
|
if (!next || next.startsWith("-")) return {
|
|
19
40
|
ok: false,
|
|
20
41
|
message: `Missing value for ${flagDesc}`
|
|
@@ -30,84 +51,97 @@ function parsePortString(s) {
|
|
|
30
51
|
if (Number.isNaN(parsed) || parsed < 1 || parsed > 65535) return null;
|
|
31
52
|
return parsed;
|
|
32
53
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
if (arg === "--
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
if (arg === "--no-open") return {
|
|
40
|
-
status: "advance",
|
|
41
|
-
nextIndex: i + 1
|
|
42
|
-
};
|
|
54
|
+
function parseEarlyWebFlag(arg) {
|
|
55
|
+
if (arg === "--help" || arg === "-h") return { kind: "help" };
|
|
56
|
+
if (arg === "--version" || arg === "-V") return { kind: "version" };
|
|
57
|
+
}
|
|
58
|
+
function advanceWebArgv(argv, i, arg, body) {
|
|
59
|
+
if (arg === "--no-open") return { nextIndex: i + 1 };
|
|
43
60
|
if (arg === "--target" || arg === "-t") {
|
|
44
61
|
const r = readRequiredValue(argv, i, "--target (or -t)");
|
|
45
62
|
if (!r.ok) return {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
kind: "error",
|
|
49
|
-
message: r.message
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
state.targetDir = r.value;
|
|
53
|
-
return {
|
|
54
|
-
status: "advance",
|
|
55
|
-
nextIndex: r.nextIndex + 1
|
|
63
|
+
kind: "error",
|
|
64
|
+
message: r.message
|
|
56
65
|
};
|
|
66
|
+
body.targetAlias = r.value;
|
|
67
|
+
return { nextIndex: r.nextIndex + 1 };
|
|
57
68
|
}
|
|
58
69
|
if (arg === "--port" || arg === "-p") {
|
|
59
70
|
const r = readRequiredValue(argv, i, "--port (or -p)");
|
|
60
71
|
if (!r.ok) return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
kind: "error",
|
|
64
|
-
message: r.message
|
|
65
|
-
}
|
|
72
|
+
kind: "error",
|
|
73
|
+
message: r.message
|
|
66
74
|
};
|
|
67
75
|
const p = parsePortString(r.value);
|
|
68
76
|
if (p === null) return {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
kind: "error",
|
|
72
|
-
message: `Invalid port: ${r.value}`
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
state.port = p;
|
|
76
|
-
return {
|
|
77
|
-
status: "advance",
|
|
78
|
-
nextIndex: r.nextIndex + 1
|
|
77
|
+
kind: "error",
|
|
78
|
+
message: `Invalid port: ${r.value}`
|
|
79
79
|
};
|
|
80
|
+
body.port = p;
|
|
81
|
+
return { nextIndex: r.nextIndex + 1 };
|
|
80
82
|
}
|
|
81
|
-
if (arg.startsWith("-")) return {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
kind: "error",
|
|
85
|
-
message: `Unknown option: ${arg}`
|
|
86
|
-
}
|
|
83
|
+
if (!arg.startsWith("-")) return {
|
|
84
|
+
kind: "error",
|
|
85
|
+
message: `Unexpected argument: ${arg}`
|
|
87
86
|
};
|
|
88
|
-
return {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
if (!ENTRYPOINT_VALUE_FLAGS.has(arg)) return {
|
|
88
|
+
kind: "error",
|
|
89
|
+
message: `Unknown option: ${arg}`
|
|
90
|
+
};
|
|
91
|
+
const value = argvElementAt(argv, i + 1);
|
|
92
|
+
if (value == null || value.startsWith("-")) return {
|
|
93
|
+
kind: "error",
|
|
94
|
+
message: `${arg} requires a value.`
|
|
94
95
|
};
|
|
96
|
+
body.remoteArgs.push(arg, value);
|
|
97
|
+
return { nextIndex: i + 2 };
|
|
95
98
|
}
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
+
function partitionWebArgv(argv) {
|
|
100
|
+
const body = {
|
|
101
|
+
remoteArgs: [],
|
|
99
102
|
port: 3e3
|
|
100
103
|
};
|
|
101
104
|
let i = 0;
|
|
102
105
|
while (i < argv.length) {
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
106
|
+
const arg = argvElementAt(argv, i);
|
|
107
|
+
if (arg === void 0) break;
|
|
108
|
+
const early = parseEarlyWebFlag(arg);
|
|
109
|
+
if (early !== void 0) return early;
|
|
110
|
+
const step = advanceWebArgv(argv, i, arg, body);
|
|
111
|
+
if ("kind" in step) return step;
|
|
105
112
|
i = step.nextIndex;
|
|
106
113
|
}
|
|
114
|
+
return body;
|
|
115
|
+
}
|
|
116
|
+
function parseCliArgs(argv) {
|
|
117
|
+
const partitioned = partitionWebArgv(argv);
|
|
118
|
+
if ("kind" in partitioned) return partitioned;
|
|
119
|
+
const { remoteArgs, port, targetAlias } = partitioned;
|
|
120
|
+
let explicit;
|
|
121
|
+
try {
|
|
122
|
+
explicit = parseEntrypointRemoteArgv(remoteArgs);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
kind: "error",
|
|
126
|
+
message: error instanceof Error ? error.message : String(error)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
let usedTargetAlias = false;
|
|
130
|
+
if (targetAlias != null && explicit.dbtTarget == null) {
|
|
131
|
+
explicit = {
|
|
132
|
+
...explicit,
|
|
133
|
+
dbtTarget: targetAlias
|
|
134
|
+
};
|
|
135
|
+
usedTargetAlias = true;
|
|
136
|
+
} else if (targetAlias != null && explicit.dbtTarget != null) return {
|
|
137
|
+
kind: "error",
|
|
138
|
+
message: "Cannot use both --dbt-target and --target (or -t)."
|
|
139
|
+
};
|
|
107
140
|
return {
|
|
108
141
|
kind: "ok",
|
|
109
|
-
|
|
110
|
-
|
|
142
|
+
port,
|
|
143
|
+
explicit,
|
|
144
|
+
usedTargetAlias
|
|
111
145
|
};
|
|
112
146
|
}
|
|
113
147
|
//#endregion
|
|
@@ -215,6 +249,15 @@ var ArtifactSourceService = class {
|
|
|
215
249
|
runs = [];
|
|
216
250
|
discoveryResult = null;
|
|
217
251
|
selectedRunId = null;
|
|
252
|
+
/** Version token of artifacts the active investigation is using (ADR-0004 detect-notify-confirm). */
|
|
253
|
+
loadedVersionToken = null;
|
|
254
|
+
remoteDiscoveryRefreshPromise = null;
|
|
255
|
+
/** Bytes last committed for investigation; pins remote reads while a newer prefix version is pending. */
|
|
256
|
+
loadedArtifactCache = null;
|
|
257
|
+
/** Incremented on user configure so in-flight remote poll refresh cannot revert the session. */
|
|
258
|
+
sessionGeneration = 0;
|
|
259
|
+
/** Set when background remote list/refresh fails; surfaced via discoveryError when discovery is otherwise ok. */
|
|
260
|
+
remoteRefreshError = null;
|
|
218
261
|
constructor(options = {}) {
|
|
219
262
|
this.cwd = options.cwd ?? process.cwd();
|
|
220
263
|
this.seedFromEnv = options.seedFromEnv !== false;
|
|
@@ -243,6 +286,19 @@ var ArtifactSourceService = class {
|
|
|
243
286
|
}
|
|
244
287
|
}
|
|
245
288
|
async seedFromEnvironment() {
|
|
289
|
+
const rawDbtTarget = getDbtToolsDbtTargetFromEnv();
|
|
290
|
+
if (rawDbtTarget != null) {
|
|
291
|
+
const parsed = parseDbtToolsArtifactTarget(rawDbtTarget, this.cwd);
|
|
292
|
+
if (parsed.kind === "remote") {
|
|
293
|
+
const discovery = await this.discoverArtifactSourceInternal(parsed.provider, rawDbtTarget);
|
|
294
|
+
const selectedRunId = discovery.discoveryResult.ok && discovery.mode === "remote" ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
295
|
+
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
296
|
+
if (selectedRunId != null) await this.refreshLoadedArtifactCache();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
await this.applyLocalDirectory(parsed.resolvedPath, true);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
246
302
|
const rawTarget = getDbtToolsTargetDirFromEnv();
|
|
247
303
|
if (rawTarget == null) return;
|
|
248
304
|
const resolved = resolveLocalArtifactTargetDirFromEnv(this.cwd, rawTarget);
|
|
@@ -295,7 +351,7 @@ var ArtifactSourceService = class {
|
|
|
295
351
|
return this.mode;
|
|
296
352
|
}
|
|
297
353
|
buildActiveArtifactStatus() {
|
|
298
|
-
const discoveryError = this.discoveryErrorMessage();
|
|
354
|
+
const discoveryError = this.discoveryErrorMessage() ?? this.remoteRefreshError;
|
|
299
355
|
const currentResolved = this.resolveSelectedRun();
|
|
300
356
|
const currentRunUi = this.runToUiOrNull(currentResolved);
|
|
301
357
|
const pendingRun = this.pendingRunAfterLatest(currentResolved);
|
|
@@ -322,11 +378,60 @@ var ArtifactSourceService = class {
|
|
|
322
378
|
missingOptionalArtifacts
|
|
323
379
|
};
|
|
324
380
|
}
|
|
325
|
-
|
|
381
|
+
syncLoadedVersionToken(selectedRunId, runs) {
|
|
382
|
+
if (selectedRunId == null) {
|
|
383
|
+
this.loadedVersionToken = null;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
this.loadedVersionToken = runs.find((candidate) => candidate.runId === selectedRunId)?.versionToken ?? null;
|
|
387
|
+
}
|
|
388
|
+
pendingRunAfterLatest(_currentResolved) {
|
|
326
389
|
const latestRun = this.runs[0] ?? null;
|
|
327
|
-
if (this.mode !== "remote" || this.remoteProvider == null || latestRun == null
|
|
390
|
+
if (this.mode !== "remote" || this.remoteProvider == null || latestRun == null) return null;
|
|
391
|
+
if (this.loadedVersionToken == null || latestRun.versionToken === this.loadedVersionToken) return null;
|
|
328
392
|
return runToUiRow("remote", this.remoteProvider, latestRun);
|
|
329
393
|
}
|
|
394
|
+
/** Re-list the remote prefix so polling can detect newer artifact pairs (ADR-0004). */
|
|
395
|
+
async refreshRemoteDiscovery() {
|
|
396
|
+
if (this.mode !== "remote" || this.remoteConfig == null || this.remoteClient == null) return;
|
|
397
|
+
if (this.remoteDiscoveryRefreshPromise != null) return this.remoteDiscoveryRefreshPromise;
|
|
398
|
+
this.remoteDiscoveryRefreshPromise = this.refreshRemoteDiscoveryInternal().finally(() => {
|
|
399
|
+
this.remoteDiscoveryRefreshPromise = null;
|
|
400
|
+
});
|
|
401
|
+
return this.remoteDiscoveryRefreshPromise;
|
|
402
|
+
}
|
|
403
|
+
async refreshRemoteDiscoveryInternal() {
|
|
404
|
+
if (this.mode !== "remote" || this.remoteConfig == null || this.remoteClient == null) return;
|
|
405
|
+
const binding = captureSessionBinding(this.sessionGeneration, null);
|
|
406
|
+
try {
|
|
407
|
+
const discovery = await this.discoverRemoteConfiguration(this.remoteConfig, this.remoteClient);
|
|
408
|
+
if (!discovery.discoveryResult.ok) {
|
|
409
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, null)) this.remoteRefreshError = discovery.discoveryResult.failure.message ?? "Remote artifact discovery failed.";
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (!isSessionBindingCurrent(binding, this.sessionGeneration, null)) return;
|
|
413
|
+
this.remoteRefreshError = null;
|
|
414
|
+
this.applyDiscoveredArtifactSource(discovery, this.selectedRunId, { commitLoadedVersion: false });
|
|
415
|
+
} catch (error) {
|
|
416
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, null)) this.remoteRefreshError = error instanceof Error ? error.message : "Remote artifact discovery refresh failed.";
|
|
417
|
+
debugLog("Remote discovery refresh failed", error);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
async readCurrentArtifactPayload(run) {
|
|
421
|
+
if (this.mode === "preload" && this.localDir != null) return this.readPreloadArtifacts(run);
|
|
422
|
+
if (this.mode === "remote" && this.remoteClient != null && this.remoteConfig != null) return this.readRemoteArtifacts(run, this.remoteConfig.bucket, this.remoteClient);
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
async refreshLoadedArtifactCache() {
|
|
426
|
+
const binding = captureSessionBinding(this.sessionGeneration, this.selectedRunId);
|
|
427
|
+
const run = this.resolveSelectedRun();
|
|
428
|
+
if (run == null || this.discoveryResult?.ok !== true) {
|
|
429
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, this.selectedRunId)) this.loadedArtifactCache = null;
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const payload = await this.readCurrentArtifactPayload(run);
|
|
433
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, this.selectedRunId)) this.loadedArtifactCache = payload;
|
|
434
|
+
}
|
|
330
435
|
async readPreloadArtifacts(run) {
|
|
331
436
|
const encoder = new TextEncoder();
|
|
332
437
|
const [manifestText, runResultsText, catalogText, sourcesText] = await Promise.all([
|
|
@@ -378,7 +483,7 @@ var ArtifactSourceService = class {
|
|
|
378
483
|
if (trimmedRunId != null && trimmedRunId !== "" && trimmedRunId !== sole.runId) throw new Error(`Unknown run id "${trimmedRunId}".`);
|
|
379
484
|
return sole.runId;
|
|
380
485
|
}
|
|
381
|
-
applyDiscoveredArtifactSource(discovery, selectedRunId) {
|
|
486
|
+
applyDiscoveredArtifactSource(discovery, selectedRunId, options) {
|
|
382
487
|
this.mode = discovery.mode;
|
|
383
488
|
this.localDir = discovery.localDir;
|
|
384
489
|
this.locationDisplay = discovery.locationDisplay;
|
|
@@ -389,6 +494,10 @@ var ArtifactSourceService = class {
|
|
|
389
494
|
this.discoveryResult = discovery.discoveryResult;
|
|
390
495
|
this.runs = discovery.runs;
|
|
391
496
|
this.selectedRunId = selectedRunId;
|
|
497
|
+
if (options?.commitLoadedVersion !== false) {
|
|
498
|
+
this.syncLoadedVersionToken(selectedRunId, discovery.runs);
|
|
499
|
+
this.loadedArtifactCache = null;
|
|
500
|
+
}
|
|
392
501
|
}
|
|
393
502
|
async discoverLocalDirectory(resolvedDir) {
|
|
394
503
|
const { runs, discovery } = await discoverLocalResolvedArtifactRuns(resolvedDir);
|
|
@@ -438,11 +547,13 @@ var ArtifactSourceService = class {
|
|
|
438
547
|
const discovery = await this.discoverLocalDirectory(resolvedDir);
|
|
439
548
|
const selectedRunId = discovery.discoveryResult.ok && fromEnvBootstrap ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
440
549
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
550
|
+
if (selectedRunId != null) await this.refreshLoadedArtifactCache();
|
|
441
551
|
}
|
|
442
552
|
async applyRemoteConfiguration(config, client, fromEnvBootstrap) {
|
|
443
553
|
const discovery = await this.discoverRemoteConfiguration(config, client);
|
|
444
554
|
const selectedRunId = discovery.discoveryResult.ok && fromEnvBootstrap ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
445
555
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
556
|
+
if (selectedRunId != null) await this.refreshLoadedArtifactCache();
|
|
446
557
|
}
|
|
447
558
|
async discoverArtifactSource(kind, location, providerOptions) {
|
|
448
559
|
await this.ensureReady();
|
|
@@ -459,9 +570,13 @@ var ArtifactSourceService = class {
|
|
|
459
570
|
*/
|
|
460
571
|
async configureArtifactSource(kind, location, runId, providerOptions) {
|
|
461
572
|
await this.ensureReady();
|
|
573
|
+
this.sessionGeneration += 1;
|
|
574
|
+
const binding = captureSessionBinding(this.sessionGeneration, null);
|
|
462
575
|
const discovery = await this.discoverArtifactSourceInternal(kind, location, providerOptions);
|
|
576
|
+
if (!isSessionBindingCurrent(binding, this.sessionGeneration, null)) return this.getStatus();
|
|
463
577
|
const selectedRunId = this.resolveConfiguredRunId(discovery, runId);
|
|
464
578
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
579
|
+
await this.refreshLoadedArtifactCache();
|
|
465
580
|
return this.getStatus();
|
|
466
581
|
}
|
|
467
582
|
async getStatus() {
|
|
@@ -470,24 +585,52 @@ var ArtifactSourceService = class {
|
|
|
470
585
|
if (this.mode === "none") return this.statusWhenNone();
|
|
471
586
|
return toArtifactSourceStatus(this.buildActiveArtifactStatus());
|
|
472
587
|
}
|
|
588
|
+
/** Re-list remote prefix and merge discovery (poll / explicit refresh). */
|
|
589
|
+
async refreshRemoteArtifactDiscovery() {
|
|
590
|
+
await this.ensureReady();
|
|
591
|
+
if (this.delegatedAdapter != null) return this.delegatedAdapter.getStatus();
|
|
592
|
+
if (this.mode === "remote") await this.refreshRemoteDiscovery();
|
|
593
|
+
return this.getStatus();
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Switch to a pending remote run and return status plus current artifact bytes.
|
|
597
|
+
* Server commits run selection and artifact cache before the client loads analysis.
|
|
598
|
+
*/
|
|
599
|
+
async acceptPendingRemoteRun(runId) {
|
|
600
|
+
await this.ensureReady();
|
|
601
|
+
if (this.delegatedAdapter != null) throw new Error("acceptPendingRemoteRun is not supported with a delegated adapter.");
|
|
602
|
+
if (this.mode !== "remote") throw new Error("acceptPendingRemoteRun requires a remote artifact source.");
|
|
603
|
+
const trimmed = runId.trim();
|
|
604
|
+
if (trimmed === "") throw new Error("runId is required.");
|
|
605
|
+
if (!this.runs.some((run) => run.runId === trimmed)) throw new Error(`Unknown artifact run id: ${trimmed}`);
|
|
606
|
+
this.selectedRunId = trimmed;
|
|
607
|
+
this.syncLoadedVersionToken(this.selectedRunId, this.runs);
|
|
608
|
+
this.loadedArtifactCache = null;
|
|
609
|
+
await this.refreshLoadedArtifactCache();
|
|
610
|
+
return this.getStatus();
|
|
611
|
+
}
|
|
473
612
|
async getCurrentArtifacts() {
|
|
474
613
|
await this.ensureReady();
|
|
475
614
|
if (this.delegatedAdapter != null) return this.delegatedAdapter.getCurrentArtifacts();
|
|
476
615
|
if (this.selectedRunId == null || this.discoveryResult?.ok !== true) return null;
|
|
477
616
|
const run = this.runs.find((r) => r.runId === this.selectedRunId);
|
|
478
617
|
if (run == null) return null;
|
|
479
|
-
if (this.mode === "
|
|
480
|
-
|
|
481
|
-
|
|
618
|
+
if (this.mode === "remote" && this.loadedArtifactCache != null && this.loadedVersionToken != null) return this.loadedArtifactCache;
|
|
619
|
+
const payload = await this.readCurrentArtifactPayload(run);
|
|
620
|
+
if (payload != null && this.mode === "remote" && this.loadedVersionToken != null && run.versionToken === this.loadedVersionToken) this.loadedArtifactCache = payload;
|
|
621
|
+
return payload;
|
|
482
622
|
}
|
|
483
623
|
async switchToRun(runId) {
|
|
484
624
|
await this.ensureReady();
|
|
485
625
|
if (this.delegatedAdapter != null) return this.delegatedAdapter.switchToRun(runId);
|
|
486
626
|
if (runId != null && runId.trim() !== "") {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
627
|
+
const trimmed = runId.trim();
|
|
628
|
+
if (!this.runs.some((r) => r.runId === trimmed)) throw new Error(`Unknown artifact run id: ${trimmed}`);
|
|
629
|
+
this.selectedRunId = trimmed;
|
|
630
|
+
this.syncLoadedVersionToken(this.selectedRunId, this.runs);
|
|
631
|
+
this.loadedArtifactCache = null;
|
|
632
|
+
await this.refreshLoadedArtifactCache();
|
|
633
|
+
debugLog("Selected artifact run", this.selectedRunId);
|
|
491
634
|
}
|
|
492
635
|
return this.getStatus();
|
|
493
636
|
}
|
|
@@ -562,6 +705,12 @@ function isArtifactStatusRequest(req, pathname) {
|
|
|
562
705
|
function isArtifactSwitchRequest(req, pathname) {
|
|
563
706
|
return req.method === "POST" && pathname === "/api/artifact-source/switch";
|
|
564
707
|
}
|
|
708
|
+
function isArtifactRefreshRequest(req, pathname) {
|
|
709
|
+
return req.method === "POST" && pathname === "/api/artifact-source/refresh";
|
|
710
|
+
}
|
|
711
|
+
function isArtifactAcceptPendingRequest(req, pathname) {
|
|
712
|
+
return req.method === "POST" && pathname === "/api/artifact-source/accept-pending-run";
|
|
713
|
+
}
|
|
565
714
|
function isArtifactConfigureRequest(req, pathname) {
|
|
566
715
|
return req.method === "POST" && pathname === "/api/artifact-source/configure";
|
|
567
716
|
}
|
|
@@ -577,7 +726,27 @@ async function respondArtifactStatus(res, service) {
|
|
|
577
726
|
async function respondArtifactSwitch(req, res, service) {
|
|
578
727
|
const body = await readJsonBody(req);
|
|
579
728
|
const runId = typeof body.runId === "string" && body.runId.trim() !== "" ? body.runId : void 0;
|
|
580
|
-
|
|
729
|
+
try {
|
|
730
|
+
sendJson(res, 200, await service.switchToRun(runId));
|
|
731
|
+
} catch (error) {
|
|
732
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : "Failed to switch artifact run." });
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async function respondArtifactRefresh(res, service) {
|
|
736
|
+
try {
|
|
737
|
+
sendJson(res, 200, await service.refreshRemoteArtifactDiscovery());
|
|
738
|
+
} catch (error) {
|
|
739
|
+
sendJson(res, 500, { error: error instanceof Error ? error.message : "Remote artifact discovery refresh failed." });
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
async function respondArtifactAcceptPending(req, res, service) {
|
|
743
|
+
const body = await readJsonBody(req);
|
|
744
|
+
const runId = typeof body.runId === "string" ? body.runId : "";
|
|
745
|
+
try {
|
|
746
|
+
sendJson(res, 200, await service.acceptPendingRemoteRun(runId));
|
|
747
|
+
} catch (error) {
|
|
748
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : "Failed to accept pending remote run." });
|
|
749
|
+
}
|
|
581
750
|
}
|
|
582
751
|
async function respondArtifactConfigure(req, res, service) {
|
|
583
752
|
const body = await readJsonBody(req);
|
|
@@ -649,6 +818,14 @@ async function tryHandleArtifactSourceViteRequest(req, res, service) {
|
|
|
649
818
|
await respondArtifactSwitch(req, res, service);
|
|
650
819
|
return true;
|
|
651
820
|
}
|
|
821
|
+
if (isArtifactRefreshRequest(req, pathname)) {
|
|
822
|
+
await respondArtifactRefresh(res, service);
|
|
823
|
+
return true;
|
|
824
|
+
}
|
|
825
|
+
if (isArtifactAcceptPendingRequest(req, pathname)) {
|
|
826
|
+
await respondArtifactAcceptPending(req, res, service);
|
|
827
|
+
return true;
|
|
828
|
+
}
|
|
652
829
|
if (isArtifactConfigureRequest(req, pathname)) {
|
|
653
830
|
await respondArtifactConfigure(req, res, service);
|
|
654
831
|
return true;
|
|
@@ -802,12 +979,25 @@ if (parsed.kind === "help") {
|
|
|
802
979
|
process.stdout.write(USAGE);
|
|
803
980
|
process.exit(0);
|
|
804
981
|
}
|
|
982
|
+
if (parsed.kind === "version") {
|
|
983
|
+
process.stdout.write(`${readWebPackageVersion()}\n`);
|
|
984
|
+
process.exit(0);
|
|
985
|
+
}
|
|
805
986
|
if (parsed.kind === "error") {
|
|
806
987
|
process.stderr.write(`${parsed.message}\n`);
|
|
807
988
|
process.exit(1);
|
|
808
989
|
}
|
|
809
|
-
var {
|
|
810
|
-
|
|
990
|
+
var { port, explicit, usedTargetAlias } = parsed;
|
|
991
|
+
try {
|
|
992
|
+
const resolved = resolveEntrypointRemoteOptions(explicit);
|
|
993
|
+
applyEntrypointRemoteOptionsToEnv(explicit);
|
|
994
|
+
if (usedTargetAlias && resolved.dbtTarget != null) {
|
|
995
|
+
if (parseDbtToolsArtifactTarget(resolved.dbtTarget, process.cwd()).kind === "local") process.env.DBT_TOOLS_TARGET_DIR = resolved.dbtTarget;
|
|
996
|
+
}
|
|
997
|
+
} catch (error) {
|
|
998
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
999
|
+
process.exit(1);
|
|
1000
|
+
}
|
|
811
1001
|
await startServer(port);
|
|
812
1002
|
var url = `http://${LISTEN_HOST}:${port}`;
|
|
813
1003
|
process.stdout.write(`dbt-tools-web ${url}\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbt-tools/web",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Browser UI for deterministic dbt artifact investigation — dependencies, execution timelines, inventory (no LLM required)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dbt",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/yu-iskw/dbt-tools-ts/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://
|
|
20
|
+
"homepage": "https://yu-iskw.github.io/dbt-tools-ts/",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-dom": "^19.2.4",
|
|
39
39
|
"react-markdown": "^10.1.0",
|
|
40
40
|
"remark-gfm": "^4.0.1",
|
|
41
|
-
"@dbt-tools/core": "0.6.
|
|
41
|
+
"@dbt-tools/core": "0.6.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@playwright/test": "^1.59.1",
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<svg
|
|
2
|
-
width="640"
|
|
3
|
-
height="540"
|
|
4
|
-
viewBox="0 0 640 540"
|
|
5
|
-
fill="none"
|
|
6
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
-
>
|
|
8
|
-
<defs>
|
|
9
|
-
<linearGradient id="app-logo-gradient" x1="24" y1="270" x2="594" y2="270" gradientUnits="userSpaceOnUse">
|
|
10
|
-
<stop stop-color="#5C49F5" />
|
|
11
|
-
<stop offset="1" stop-color="#5B58FF" />
|
|
12
|
-
</linearGradient>
|
|
13
|
-
<filter id="app-logo-shadow" x="0" y="16" width="618" height="508" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
14
|
-
<feFlood flood-opacity="0" result="BackgroundImageFix" />
|
|
15
|
-
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" />
|
|
16
|
-
<feOffset dy="6" />
|
|
17
|
-
<feGaussianBlur stdDeviation="8" />
|
|
18
|
-
<feColorMatrix type="matrix" values="0 0 0 0 0.176471 0 0 0 0 0.168627 0 0 0 0 0.560784 0 0 0 0.14 0" />
|
|
19
|
-
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1_1" />
|
|
20
|
-
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1_1" result="shape" />
|
|
21
|
-
</filter>
|
|
22
|
-
</defs>
|
|
23
|
-
<g filter="url(#app-logo-shadow)">
|
|
24
|
-
<rect x="108" y="34" width="270" height="68" rx="34" fill="url(#app-logo-gradient)" />
|
|
25
|
-
<rect x="276" y="142" width="318" height="68" rx="34" fill="url(#app-logo-gradient)" />
|
|
26
|
-
<rect x="24" y="246" width="430" height="72" rx="36" fill="url(#app-logo-gradient)" />
|
|
27
|
-
<rect x="220" y="352" width="292" height="68" rx="34" fill="url(#app-logo-gradient)" />
|
|
28
|
-
<rect x="108" y="458" width="236" height="68" rx="34" fill="url(#app-logo-gradient)" />
|
|
29
|
-
</g>
|
|
30
|
-
</svg>
|