@dbt-tools/web 0.6.2 → 0.7.0
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/assets/analysis.worker-32L71aED.js +64 -0
- package/dist/assets/index-CxeISj08.js +99 -0
- package/dist/assets/react-vendor-BwlCKk7e.js +9 -0
- package/dist/assets/results-query.worker-BBg-yrVz.js +64 -0
- package/dist/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/assets/tanstack-virtual-vendor-tYq3m8C_.js +4 -0
- package/dist/index.html +4 -4
- package/dist-serve/server/cli.js +207 -52
- package/package.json +5 -5
- package/dist/assets/analysis.worker-BzrXut-o.js +0 -1
- package/dist/assets/index-DRBtWycK.js +0 -36
- package/dist/assets/react-vendor-DBiqvVPF.js +0 -9
- package/dist/assets/results-query.worker-CM0N9VyM.js +0 -1
- package/dist/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
- package/dist/assets/tanstack-virtual-vendor-BfMyFx37.js +0 -4
package/dist-serve/server/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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";
|
|
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
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import http from "node:http";
|
|
5
5
|
import path from "node:path";
|
|
@@ -27,7 +27,7 @@ var USAGE = [
|
|
|
27
27
|
" -V, --version Print package version",
|
|
28
28
|
" -h, --help Show this help"
|
|
29
29
|
].join("\n");
|
|
30
|
-
var ENTRYPOINT_VALUE_FLAGS = new Set([
|
|
30
|
+
var ENTRYPOINT_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
31
31
|
"--dbt-target",
|
|
32
32
|
"--gcs-project-id",
|
|
33
33
|
"--gcs-impersonate-service-account",
|
|
@@ -177,7 +177,8 @@ async function discoverLocalResolvedArtifactRuns(resolvedDirAbs) {
|
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
function discoverRemoteArtifactDiscovery(objects, prefix) {
|
|
180
|
-
|
|
180
|
+
const listed = remoteKeysToListedArtifacts(objects, prefix);
|
|
181
|
+
return discoverArtifactCandidates(listed);
|
|
181
182
|
}
|
|
182
183
|
function discoverLatestArtifactRuns(objects, prefix) {
|
|
183
184
|
const disc = discoverRemoteArtifactDiscovery(objects, prefix);
|
|
@@ -210,6 +211,49 @@ function resolveLocalArtifactTargetDirFromEnv(cwd, rawTargetDir) {
|
|
|
210
211
|
return path.resolve(cwd, expandDbtTargetDirFromEnvValue(rawTargetDir));
|
|
211
212
|
}
|
|
212
213
|
//#endregion
|
|
214
|
+
//#region src/artifact-source/workspace-bridge.ts
|
|
215
|
+
async function readLocalRunArtifactBytes(run) {
|
|
216
|
+
const encoder = new TextEncoder();
|
|
217
|
+
const [manifestText, runResultsText, catalogText, sourcesText] = await Promise.all([
|
|
218
|
+
readValidatedUtf8(run.manifestKey),
|
|
219
|
+
readValidatedUtf8(run.runResultsKey),
|
|
220
|
+
run.catalogKey != null ? readValidatedUtf8(run.catalogKey).catch(() => null) : Promise.resolve(null),
|
|
221
|
+
run.sourcesKey != null ? readValidatedUtf8(run.sourcesKey).catch(() => null) : Promise.resolve(null)
|
|
222
|
+
]);
|
|
223
|
+
const manifestBytes = encoder.encode(manifestText);
|
|
224
|
+
const runResultsBytes = encoder.encode(runResultsText);
|
|
225
|
+
const catalogBytes = catalogText != null ? encoder.encode(catalogText) : null;
|
|
226
|
+
const sourcesBytes = sourcesText != null ? encoder.encode(sourcesText) : null;
|
|
227
|
+
return {
|
|
228
|
+
manifestBytes,
|
|
229
|
+
runResultsBytes,
|
|
230
|
+
...catalogBytes != null ? { catalogBytes } : {},
|
|
231
|
+
...sourcesBytes != null ? { sourcesBytes } : {}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
async function readRemoteRunArtifactBytes(run, bucket, client) {
|
|
235
|
+
const readOptional = async (key) => {
|
|
236
|
+
if (key == null) return null;
|
|
237
|
+
try {
|
|
238
|
+
return await client.readObjectBytes(bucket, key);
|
|
239
|
+
} catch {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const [manifestBytes, runResultsBytes, catalogBytes, sourcesBytes] = await Promise.all([
|
|
244
|
+
client.readObjectBytes(bucket, run.manifestKey),
|
|
245
|
+
client.readObjectBytes(bucket, run.runResultsKey),
|
|
246
|
+
readOptional(run.catalogKey),
|
|
247
|
+
readOptional(run.sourcesKey)
|
|
248
|
+
]);
|
|
249
|
+
return {
|
|
250
|
+
manifestBytes,
|
|
251
|
+
runResultsBytes,
|
|
252
|
+
...catalogBytes != null ? { catalogBytes } : {},
|
|
253
|
+
...sourcesBytes != null ? { sourcesBytes } : {}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
213
257
|
//#region src/artifact-source/source-service.ts
|
|
214
258
|
/** Node (Vite dev) service: configurable local path or remote S3/GCS; drives middleware routes. */
|
|
215
259
|
function debugLog(...args) {
|
|
@@ -249,6 +293,15 @@ var ArtifactSourceService = class {
|
|
|
249
293
|
runs = [];
|
|
250
294
|
discoveryResult = null;
|
|
251
295
|
selectedRunId = null;
|
|
296
|
+
/** Version token of artifacts the active investigation is using (ADR-0004 detect-notify-confirm). */
|
|
297
|
+
loadedVersionToken = null;
|
|
298
|
+
remoteDiscoveryRefreshPromise = null;
|
|
299
|
+
/** Bytes last committed for investigation; pins remote reads while a newer prefix version is pending. */
|
|
300
|
+
loadedArtifactCache = null;
|
|
301
|
+
/** Incremented on user configure so in-flight remote poll refresh cannot revert the session. */
|
|
302
|
+
sessionGeneration = 0;
|
|
303
|
+
/** Set when background remote list/refresh fails; surfaced via discoveryError when discovery is otherwise ok. */
|
|
304
|
+
remoteRefreshError = null;
|
|
252
305
|
constructor(options = {}) {
|
|
253
306
|
this.cwd = options.cwd ?? process.cwd();
|
|
254
307
|
this.seedFromEnv = options.seedFromEnv !== false;
|
|
@@ -284,6 +337,7 @@ var ArtifactSourceService = class {
|
|
|
284
337
|
const discovery = await this.discoverArtifactSourceInternal(parsed.provider, rawDbtTarget);
|
|
285
338
|
const selectedRunId = discovery.discoveryResult.ok && discovery.mode === "remote" ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
286
339
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
340
|
+
if (selectedRunId != null) await this.refreshLoadedArtifactCache();
|
|
287
341
|
return;
|
|
288
342
|
}
|
|
289
343
|
await this.applyLocalDirectory(parsed.resolvedPath, true);
|
|
@@ -341,7 +395,7 @@ var ArtifactSourceService = class {
|
|
|
341
395
|
return this.mode;
|
|
342
396
|
}
|
|
343
397
|
buildActiveArtifactStatus() {
|
|
344
|
-
const discoveryError = this.discoveryErrorMessage();
|
|
398
|
+
const discoveryError = this.discoveryErrorMessage() ?? this.remoteRefreshError;
|
|
345
399
|
const currentResolved = this.resolveSelectedRun();
|
|
346
400
|
const currentRunUi = this.runToUiOrNull(currentResolved);
|
|
347
401
|
const pendingRun = this.pendingRunAfterLatest(currentResolved);
|
|
@@ -368,52 +422,79 @@ var ArtifactSourceService = class {
|
|
|
368
422
|
missingOptionalArtifacts
|
|
369
423
|
};
|
|
370
424
|
}
|
|
371
|
-
|
|
425
|
+
syncLoadedVersionToken(selectedRunId, runs) {
|
|
426
|
+
if (selectedRunId == null) {
|
|
427
|
+
this.loadedVersionToken = null;
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
const run = runs.find((candidate) => candidate.runId === selectedRunId);
|
|
431
|
+
this.loadedVersionToken = run?.versionToken ?? null;
|
|
432
|
+
}
|
|
433
|
+
pendingRunAfterLatest(_currentResolved) {
|
|
372
434
|
const latestRun = this.runs[0] ?? null;
|
|
373
|
-
if (this.mode !== "remote" || this.remoteProvider == null || latestRun == null
|
|
435
|
+
if (this.mode !== "remote" || this.remoteProvider == null || latestRun == null) return null;
|
|
436
|
+
if (this.loadedVersionToken == null || latestRun.versionToken === this.loadedVersionToken) return null;
|
|
374
437
|
return runToUiRow("remote", this.remoteProvider, latestRun);
|
|
375
438
|
}
|
|
439
|
+
/** Re-list the remote prefix so polling can detect newer artifact pairs (ADR-0004). */
|
|
440
|
+
async refreshRemoteDiscovery() {
|
|
441
|
+
if (this.mode !== "remote" || this.remoteConfig == null || this.remoteClient == null) return;
|
|
442
|
+
if (this.remoteDiscoveryRefreshPromise != null) return this.remoteDiscoveryRefreshPromise;
|
|
443
|
+
this.remoteDiscoveryRefreshPromise = this.refreshRemoteDiscoveryInternal().finally(() => {
|
|
444
|
+
this.remoteDiscoveryRefreshPromise = null;
|
|
445
|
+
});
|
|
446
|
+
return this.remoteDiscoveryRefreshPromise;
|
|
447
|
+
}
|
|
448
|
+
async refreshRemoteDiscoveryInternal() {
|
|
449
|
+
if (this.mode !== "remote" || this.remoteConfig == null || this.remoteClient == null) return;
|
|
450
|
+
const binding = captureSessionBinding(this.sessionGeneration, null);
|
|
451
|
+
try {
|
|
452
|
+
const discovery = await this.discoverRemoteConfiguration(this.remoteConfig, this.remoteClient);
|
|
453
|
+
if (!discovery.discoveryResult.ok) {
|
|
454
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, null)) this.remoteRefreshError = discovery.discoveryResult.failure.message ?? "Remote artifact discovery failed.";
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (!isSessionBindingCurrent(binding, this.sessionGeneration, null)) return;
|
|
458
|
+
this.remoteRefreshError = null;
|
|
459
|
+
this.applyDiscoveredArtifactSource(discovery, this.selectedRunId, { commitLoadedVersion: false });
|
|
460
|
+
} catch (error) {
|
|
461
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, null)) this.remoteRefreshError = error instanceof Error ? error.message : "Remote artifact discovery refresh failed.";
|
|
462
|
+
debugLog("Remote discovery refresh failed", error);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async readCurrentArtifactPayload(run) {
|
|
466
|
+
if (this.mode === "preload" && this.localDir != null) return this.readPreloadArtifacts(run);
|
|
467
|
+
if (this.mode === "remote" && this.remoteClient != null && this.remoteConfig != null) return this.readRemoteArtifacts(run, this.remoteConfig.bucket, this.remoteClient);
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
async refreshLoadedArtifactCache() {
|
|
471
|
+
const binding = captureSessionBinding(this.sessionGeneration, this.selectedRunId);
|
|
472
|
+
const run = this.resolveSelectedRun();
|
|
473
|
+
if (run == null || this.discoveryResult?.ok !== true) {
|
|
474
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, this.selectedRunId)) this.loadedArtifactCache = null;
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const payload = await this.readCurrentArtifactPayload(run);
|
|
478
|
+
if (isSessionBindingCurrent(binding, this.sessionGeneration, this.selectedRunId)) this.loadedArtifactCache = payload;
|
|
479
|
+
}
|
|
376
480
|
async readPreloadArtifacts(run) {
|
|
377
|
-
const
|
|
378
|
-
const [manifestText, runResultsText, catalogText, sourcesText] = await Promise.all([
|
|
379
|
-
readValidatedUtf8(run.manifestKey),
|
|
380
|
-
readValidatedUtf8(run.runResultsKey),
|
|
381
|
-
run.catalogKey != null ? readValidatedUtf8(run.catalogKey).catch(() => null) : Promise.resolve(null),
|
|
382
|
-
run.sourcesKey != null ? readValidatedUtf8(run.sourcesKey).catch(() => null) : Promise.resolve(null)
|
|
383
|
-
]);
|
|
384
|
-
const manifestBytes = encoder.encode(manifestText);
|
|
385
|
-
const runResultsBytes = encoder.encode(runResultsText);
|
|
386
|
-
const catalogBytes = catalogText != null ? encoder.encode(catalogText) : null;
|
|
387
|
-
const sourcesBytes = sourcesText != null ? encoder.encode(sourcesText) : null;
|
|
481
|
+
const bytes = await readLocalRunArtifactBytes(run);
|
|
388
482
|
return {
|
|
389
483
|
source: "preload",
|
|
390
|
-
manifestBytes,
|
|
391
|
-
runResultsBytes,
|
|
392
|
-
...catalogBytes != null ? { catalogBytes } : {},
|
|
393
|
-
...sourcesBytes != null ? { sourcesBytes } : {}
|
|
484
|
+
manifestBytes: bytes.manifestBytes,
|
|
485
|
+
runResultsBytes: bytes.runResultsBytes,
|
|
486
|
+
...bytes.catalogBytes != null ? { catalogBytes: bytes.catalogBytes } : {},
|
|
487
|
+
...bytes.sourcesBytes != null ? { sourcesBytes: bytes.sourcesBytes } : {}
|
|
394
488
|
};
|
|
395
489
|
}
|
|
396
490
|
async readRemoteArtifacts(run, bucket, client) {
|
|
397
|
-
const
|
|
398
|
-
if (key == null) return null;
|
|
399
|
-
try {
|
|
400
|
-
return await client.readObjectBytes(bucket, key);
|
|
401
|
-
} catch {
|
|
402
|
-
return null;
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
const [manifestBytes, runResultsBytes, catalogBytes, sourcesBytes] = await Promise.all([
|
|
406
|
-
client.readObjectBytes(bucket, run.manifestKey),
|
|
407
|
-
client.readObjectBytes(bucket, run.runResultsKey),
|
|
408
|
-
readOptional(run.catalogKey),
|
|
409
|
-
readOptional(run.sourcesKey)
|
|
410
|
-
]);
|
|
491
|
+
const bytes = await readRemoteRunArtifactBytes(run, bucket, client);
|
|
411
492
|
return {
|
|
412
493
|
source: "remote",
|
|
413
|
-
manifestBytes,
|
|
414
|
-
runResultsBytes,
|
|
415
|
-
...catalogBytes != null ? { catalogBytes } : {},
|
|
416
|
-
...sourcesBytes != null ? { sourcesBytes } : {}
|
|
494
|
+
manifestBytes: bytes.manifestBytes,
|
|
495
|
+
runResultsBytes: bytes.runResultsBytes,
|
|
496
|
+
...bytes.catalogBytes != null ? { catalogBytes: bytes.catalogBytes } : {},
|
|
497
|
+
...bytes.sourcesBytes != null ? { sourcesBytes: bytes.sourcesBytes } : {}
|
|
417
498
|
};
|
|
418
499
|
}
|
|
419
500
|
resolveConfiguredRunId(discovery, runId) {
|
|
@@ -424,7 +505,7 @@ var ArtifactSourceService = class {
|
|
|
424
505
|
if (trimmedRunId != null && trimmedRunId !== "" && trimmedRunId !== sole.runId) throw new Error(`Unknown run id "${trimmedRunId}".`);
|
|
425
506
|
return sole.runId;
|
|
426
507
|
}
|
|
427
|
-
applyDiscoveredArtifactSource(discovery, selectedRunId) {
|
|
508
|
+
applyDiscoveredArtifactSource(discovery, selectedRunId, options) {
|
|
428
509
|
this.mode = discovery.mode;
|
|
429
510
|
this.localDir = discovery.localDir;
|
|
430
511
|
this.locationDisplay = discovery.locationDisplay;
|
|
@@ -435,6 +516,10 @@ var ArtifactSourceService = class {
|
|
|
435
516
|
this.discoveryResult = discovery.discoveryResult;
|
|
436
517
|
this.runs = discovery.runs;
|
|
437
518
|
this.selectedRunId = selectedRunId;
|
|
519
|
+
if (options?.commitLoadedVersion !== false) {
|
|
520
|
+
this.syncLoadedVersionToken(selectedRunId, discovery.runs);
|
|
521
|
+
this.loadedArtifactCache = null;
|
|
522
|
+
}
|
|
438
523
|
}
|
|
439
524
|
async discoverLocalDirectory(resolvedDir) {
|
|
440
525
|
const { runs, discovery } = await discoverLocalResolvedArtifactRuns(resolvedDir);
|
|
@@ -473,10 +558,11 @@ var ArtifactSourceService = class {
|
|
|
473
558
|
const parsed = parseArtifactSourceLocation(kind, location, this.cwd);
|
|
474
559
|
if (parsed.kind === "local") return this.discoverLocalDirectory(parsed.resolvedPath);
|
|
475
560
|
const envClient = getDbtToolsRemoteClientEnvFromEnv();
|
|
476
|
-
const
|
|
561
|
+
const gcsRequestOptions = kind === "gcs" ? {
|
|
477
562
|
...envClient.gcsRequestOptions,
|
|
478
563
|
...providerOptions
|
|
479
|
-
} : void 0
|
|
564
|
+
} : void 0;
|
|
565
|
+
const merged = mergeRemoteSourceConfigWithParsedLocation(void 0, parsed, gcsRequestOptions, envClient.remoteClientOverrides);
|
|
480
566
|
const client = await createRemoteObjectStoreClient(merged);
|
|
481
567
|
return this.discoverRemoteConfiguration(merged, client);
|
|
482
568
|
}
|
|
@@ -484,11 +570,13 @@ var ArtifactSourceService = class {
|
|
|
484
570
|
const discovery = await this.discoverLocalDirectory(resolvedDir);
|
|
485
571
|
const selectedRunId = discovery.discoveryResult.ok && fromEnvBootstrap ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
486
572
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
573
|
+
if (selectedRunId != null) await this.refreshLoadedArtifactCache();
|
|
487
574
|
}
|
|
488
575
|
async applyRemoteConfiguration(config, client, fromEnvBootstrap) {
|
|
489
576
|
const discovery = await this.discoverRemoteConfiguration(config, client);
|
|
490
577
|
const selectedRunId = discovery.discoveryResult.ok && fromEnvBootstrap ? this.pickBootstrapRunId(discovery.runs) : null;
|
|
491
578
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
579
|
+
if (selectedRunId != null) await this.refreshLoadedArtifactCache();
|
|
492
580
|
}
|
|
493
581
|
async discoverArtifactSource(kind, location, providerOptions) {
|
|
494
582
|
await this.ensureReady();
|
|
@@ -505,9 +593,13 @@ var ArtifactSourceService = class {
|
|
|
505
593
|
*/
|
|
506
594
|
async configureArtifactSource(kind, location, runId, providerOptions) {
|
|
507
595
|
await this.ensureReady();
|
|
596
|
+
this.sessionGeneration += 1;
|
|
597
|
+
const binding = captureSessionBinding(this.sessionGeneration, null);
|
|
508
598
|
const discovery = await this.discoverArtifactSourceInternal(kind, location, providerOptions);
|
|
599
|
+
if (!isSessionBindingCurrent(binding, this.sessionGeneration, null)) return this.getStatus();
|
|
509
600
|
const selectedRunId = this.resolveConfiguredRunId(discovery, runId);
|
|
510
601
|
this.applyDiscoveredArtifactSource(discovery, selectedRunId);
|
|
602
|
+
await this.refreshLoadedArtifactCache();
|
|
511
603
|
return this.getStatus();
|
|
512
604
|
}
|
|
513
605
|
async getStatus() {
|
|
@@ -516,24 +608,52 @@ var ArtifactSourceService = class {
|
|
|
516
608
|
if (this.mode === "none") return this.statusWhenNone();
|
|
517
609
|
return toArtifactSourceStatus(this.buildActiveArtifactStatus());
|
|
518
610
|
}
|
|
611
|
+
/** Re-list remote prefix and merge discovery (poll / explicit refresh). */
|
|
612
|
+
async refreshRemoteArtifactDiscovery() {
|
|
613
|
+
await this.ensureReady();
|
|
614
|
+
if (this.delegatedAdapter != null) return this.delegatedAdapter.getStatus();
|
|
615
|
+
if (this.mode === "remote") await this.refreshRemoteDiscovery();
|
|
616
|
+
return this.getStatus();
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Switch to a pending remote run and return status plus current artifact bytes.
|
|
620
|
+
* Server commits run selection and artifact cache before the client loads analysis.
|
|
621
|
+
*/
|
|
622
|
+
async acceptPendingRemoteRun(runId) {
|
|
623
|
+
await this.ensureReady();
|
|
624
|
+
if (this.delegatedAdapter != null) throw new Error("acceptPendingRemoteRun is not supported with a delegated adapter.");
|
|
625
|
+
if (this.mode !== "remote") throw new Error("acceptPendingRemoteRun requires a remote artifact source.");
|
|
626
|
+
const trimmed = runId.trim();
|
|
627
|
+
if (trimmed === "") throw new Error("runId is required.");
|
|
628
|
+
if (!this.runs.some((run) => run.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
|
+
return this.getStatus();
|
|
634
|
+
}
|
|
519
635
|
async getCurrentArtifacts() {
|
|
520
636
|
await this.ensureReady();
|
|
521
637
|
if (this.delegatedAdapter != null) return this.delegatedAdapter.getCurrentArtifacts();
|
|
522
638
|
if (this.selectedRunId == null || this.discoveryResult?.ok !== true) return null;
|
|
523
639
|
const run = this.runs.find((r) => r.runId === this.selectedRunId);
|
|
524
640
|
if (run == null) return null;
|
|
525
|
-
if (this.mode === "
|
|
526
|
-
|
|
527
|
-
|
|
641
|
+
if (this.mode === "remote" && this.loadedArtifactCache != null && this.loadedVersionToken != null) return this.loadedArtifactCache;
|
|
642
|
+
const payload = await this.readCurrentArtifactPayload(run);
|
|
643
|
+
if (payload != null && this.mode === "remote" && this.loadedVersionToken != null && run.versionToken === this.loadedVersionToken) this.loadedArtifactCache = payload;
|
|
644
|
+
return payload;
|
|
528
645
|
}
|
|
529
646
|
async switchToRun(runId) {
|
|
530
647
|
await this.ensureReady();
|
|
531
648
|
if (this.delegatedAdapter != null) return this.delegatedAdapter.switchToRun(runId);
|
|
532
649
|
if (runId != null && runId.trim() !== "") {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
650
|
+
const trimmed = runId.trim();
|
|
651
|
+
if (!this.runs.some((r) => r.runId === trimmed)) throw new Error(`Unknown artifact run id: ${trimmed}`);
|
|
652
|
+
this.selectedRunId = trimmed;
|
|
653
|
+
this.syncLoadedVersionToken(this.selectedRunId, this.runs);
|
|
654
|
+
this.loadedArtifactCache = null;
|
|
655
|
+
await this.refreshLoadedArtifactCache();
|
|
656
|
+
debugLog("Selected artifact run", this.selectedRunId);
|
|
537
657
|
}
|
|
538
658
|
return this.getStatus();
|
|
539
659
|
}
|
|
@@ -589,7 +709,7 @@ function currentArtifactBytes(pathname, current) {
|
|
|
589
709
|
if (pathname.endsWith(DBT_SOURCES_JSON)) return current.sourcesBytes ?? null;
|
|
590
710
|
return null;
|
|
591
711
|
}
|
|
592
|
-
var CURRENT_ARTIFACT_PATHS = new Set([
|
|
712
|
+
var CURRENT_ARTIFACT_PATHS = /* @__PURE__ */ new Set([
|
|
593
713
|
`/api/${DBT_MANIFEST_JSON}`,
|
|
594
714
|
`/api/artifacts/current/${DBT_MANIFEST_JSON}`,
|
|
595
715
|
`/api/${DBT_RUN_RESULTS_JSON}`,
|
|
@@ -608,6 +728,12 @@ function isArtifactStatusRequest(req, pathname) {
|
|
|
608
728
|
function isArtifactSwitchRequest(req, pathname) {
|
|
609
729
|
return req.method === "POST" && pathname === "/api/artifact-source/switch";
|
|
610
730
|
}
|
|
731
|
+
function isArtifactRefreshRequest(req, pathname) {
|
|
732
|
+
return req.method === "POST" && pathname === "/api/artifact-source/refresh";
|
|
733
|
+
}
|
|
734
|
+
function isArtifactAcceptPendingRequest(req, pathname) {
|
|
735
|
+
return req.method === "POST" && pathname === "/api/artifact-source/accept-pending-run";
|
|
736
|
+
}
|
|
611
737
|
function isArtifactConfigureRequest(req, pathname) {
|
|
612
738
|
return req.method === "POST" && pathname === "/api/artifact-source/configure";
|
|
613
739
|
}
|
|
@@ -623,7 +749,27 @@ async function respondArtifactStatus(res, service) {
|
|
|
623
749
|
async function respondArtifactSwitch(req, res, service) {
|
|
624
750
|
const body = await readJsonBody(req);
|
|
625
751
|
const runId = typeof body.runId === "string" && body.runId.trim() !== "" ? body.runId : void 0;
|
|
626
|
-
|
|
752
|
+
try {
|
|
753
|
+
sendJson(res, 200, await service.switchToRun(runId));
|
|
754
|
+
} catch (error) {
|
|
755
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : "Failed to switch artifact run." });
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
async function respondArtifactRefresh(res, service) {
|
|
759
|
+
try {
|
|
760
|
+
sendJson(res, 200, await service.refreshRemoteArtifactDiscovery());
|
|
761
|
+
} catch (error) {
|
|
762
|
+
sendJson(res, 500, { error: error instanceof Error ? error.message : "Remote artifact discovery refresh failed." });
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
async function respondArtifactAcceptPending(req, res, service) {
|
|
766
|
+
const body = await readJsonBody(req);
|
|
767
|
+
const runId = typeof body.runId === "string" ? body.runId : "";
|
|
768
|
+
try {
|
|
769
|
+
sendJson(res, 200, await service.acceptPendingRemoteRun(runId));
|
|
770
|
+
} catch (error) {
|
|
771
|
+
sendJson(res, 400, { error: error instanceof Error ? error.message : "Failed to accept pending remote run." });
|
|
772
|
+
}
|
|
627
773
|
}
|
|
628
774
|
async function respondArtifactConfigure(req, res, service) {
|
|
629
775
|
const body = await readJsonBody(req);
|
|
@@ -695,6 +841,14 @@ async function tryHandleArtifactSourceViteRequest(req, res, service) {
|
|
|
695
841
|
await respondArtifactSwitch(req, res, service);
|
|
696
842
|
return true;
|
|
697
843
|
}
|
|
844
|
+
if (isArtifactRefreshRequest(req, pathname)) {
|
|
845
|
+
await respondArtifactRefresh(res, service);
|
|
846
|
+
return true;
|
|
847
|
+
}
|
|
848
|
+
if (isArtifactAcceptPendingRequest(req, pathname)) {
|
|
849
|
+
await respondArtifactAcceptPending(req, res, service);
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
698
852
|
if (isArtifactConfigureRequest(req, pathname)) {
|
|
699
853
|
await respondArtifactConfigure(req, res, service);
|
|
700
854
|
return true;
|
|
@@ -799,7 +953,8 @@ function sendFileWithOptionalSpaFallback(primaryPath, res, allowSpaFallback) {
|
|
|
799
953
|
}
|
|
800
954
|
sendInternalError(res, true);
|
|
801
955
|
});
|
|
802
|
-
const
|
|
956
|
+
const ext = path.extname(safePath).toLowerCase();
|
|
957
|
+
const mime = getObjectProperty(MIME, ext) ?? "application/octet-stream";
|
|
803
958
|
res.setHeader("Content-Type", mime);
|
|
804
959
|
res.statusCode = 200;
|
|
805
960
|
stream.pipe(res);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbt-tools/web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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
|
},
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@tanstack/react-virtual": "^3.13.23",
|
|
36
|
-
"dbt-artifacts-parser": "^0.
|
|
36
|
+
"dbt-artifacts-parser": "^0.7.0",
|
|
37
37
|
"react": "^19.2.4",
|
|
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.
|
|
41
|
+
"@dbt-tools/core": "0.7.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@playwright/test": "^1.59.1",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/react-dom": "^19.2.3",
|
|
48
48
|
"@vitejs/plugin-react": "^6.0.1",
|
|
49
49
|
"typescript": "^6.0.2",
|
|
50
|
-
"vite": "^8.0
|
|
50
|
+
"vite": "^8.2.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|