@dbt-tools/web 0.6.0 → 0.6.2
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 +39 -45
- package/dist/assets/{analysis.worker-Ck5WMv4C.js → analysis.worker-BzrXut-o.js} +1 -1
- package/dist/assets/{index-C51XEijC.js → index-DRBtWycK.js} +3 -3
- package/dist/assets/{results-query.worker-SUBgXDqM.js → results-query.worker-CM0N9VyM.js} +1 -1
- 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 +130 -72
- package/package.json +2 -2
- package/dist/assets/app-logo-ByfNNtT8.svg +0 -30
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, createReadStreamValidated, discoverArtifactCandidates, discoverLocalArtifactRunPaths, entrypointRemoteHelpLines, existsValidated, getDbtToolsDbtTargetFromEnv, getDbtToolsRemoteClientEnvFromEnv, getDbtToolsTargetDirFromEnv, getObjectProperty, isDbtToolsDebugEnabled, 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, getDbtToolsRemoteSourceConfigFromEnv, 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
|
-
kind: "error",
|
|
92
|
-
message: `Unexpected argument: ${arg}`
|
|
93
|
-
}
|
|
87
|
+
if (!ENTRYPOINT_VALUE_FLAGS.has(arg)) return {
|
|
88
|
+
kind: "error",
|
|
89
|
+
message: `Unknown option: ${arg}`
|
|
94
90
|
};
|
|
91
|
+
const value = argvElementAt(argv, i + 1);
|
|
92
|
+
if (value == null || value.startsWith("-")) return {
|
|
93
|
+
kind: "error",
|
|
94
|
+
message: `${arg} requires a value.`
|
|
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
|
|
@@ -243,9 +277,16 @@ var ArtifactSourceService = class {
|
|
|
243
277
|
}
|
|
244
278
|
}
|
|
245
279
|
async seedFromEnvironment() {
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
|
|
280
|
+
const rawDbtTarget = getDbtToolsDbtTargetFromEnv();
|
|
281
|
+
if (rawDbtTarget != null) {
|
|
282
|
+
const parsed = parseDbtToolsArtifactTarget(rawDbtTarget, this.cwd);
|
|
283
|
+
if (parsed.kind === "remote") {
|
|
284
|
+
const discovery = await this.discoverArtifactSourceInternal(parsed.provider, rawDbtTarget);
|
|
285
|
+
const selectedRunId = discovery.discoveryResult.ok && discovery.mode === "remote" ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
286
|
+
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
await this.applyLocalDirectory(parsed.resolvedPath, true);
|
|
249
290
|
return;
|
|
250
291
|
}
|
|
251
292
|
const rawTarget = getDbtToolsTargetDirFromEnv();
|
|
@@ -431,7 +472,11 @@ var ArtifactSourceService = class {
|
|
|
431
472
|
async discoverArtifactSourceInternal(kind, location, providerOptions) {
|
|
432
473
|
const parsed = parseArtifactSourceLocation(kind, location, this.cwd);
|
|
433
474
|
if (parsed.kind === "local") return this.discoverLocalDirectory(parsed.resolvedPath);
|
|
434
|
-
const
|
|
475
|
+
const envClient = getDbtToolsRemoteClientEnvFromEnv();
|
|
476
|
+
const merged = mergeRemoteSourceConfigWithParsedLocation(void 0, parsed, kind === "gcs" ? {
|
|
477
|
+
...envClient.gcsRequestOptions,
|
|
478
|
+
...providerOptions
|
|
479
|
+
} : void 0, envClient.remoteClientOverrides);
|
|
435
480
|
const client = await createRemoteObjectStoreClient(merged);
|
|
436
481
|
return this.discoverRemoteConfiguration(merged, client);
|
|
437
482
|
}
|
|
@@ -783,9 +828,9 @@ function startServer(port) {
|
|
|
783
828
|
return;
|
|
784
829
|
}
|
|
785
830
|
serveStaticFile(resolveStaticPath(req.url ?? "/"), res);
|
|
786
|
-
} catch
|
|
831
|
+
} catch {
|
|
787
832
|
sendInternalError(res, false);
|
|
788
|
-
console.error("[dbt-tools-web]"
|
|
833
|
+
console.error("[dbt-tools-web] request failed");
|
|
789
834
|
}
|
|
790
835
|
})();
|
|
791
836
|
});
|
|
@@ -803,12 +848,25 @@ if (parsed.kind === "help") {
|
|
|
803
848
|
process.stdout.write(USAGE);
|
|
804
849
|
process.exit(0);
|
|
805
850
|
}
|
|
851
|
+
if (parsed.kind === "version") {
|
|
852
|
+
process.stdout.write(`${readWebPackageVersion()}\n`);
|
|
853
|
+
process.exit(0);
|
|
854
|
+
}
|
|
806
855
|
if (parsed.kind === "error") {
|
|
807
856
|
process.stderr.write(`${parsed.message}\n`);
|
|
808
857
|
process.exit(1);
|
|
809
858
|
}
|
|
810
|
-
var {
|
|
811
|
-
|
|
859
|
+
var { port, explicit, usedTargetAlias } = parsed;
|
|
860
|
+
try {
|
|
861
|
+
const resolved = resolveEntrypointRemoteOptions(explicit);
|
|
862
|
+
applyEntrypointRemoteOptionsToEnv(explicit);
|
|
863
|
+
if (usedTargetAlias && resolved.dbtTarget != null) {
|
|
864
|
+
if (parseDbtToolsArtifactTarget(resolved.dbtTarget, process.cwd()).kind === "local") process.env.DBT_TOOLS_TARGET_DIR = resolved.dbtTarget;
|
|
865
|
+
}
|
|
866
|
+
} catch (error) {
|
|
867
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
868
|
+
process.exit(1);
|
|
869
|
+
}
|
|
812
870
|
await startServer(port);
|
|
813
871
|
var url = `http://${LISTEN_HOST}:${port}`;
|
|
814
872
|
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.2",
|
|
4
4
|
"description": "Browser UI for deterministic dbt artifact investigation — dependencies, execution timelines, inventory (no LLM required)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dbt",
|
|
@@ -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.2"
|
|
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>
|