@sdt-tools/cli 0.2.0 → 0.2.6
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/advise-tests-6DRSZMBL.js +87 -0
- package/dist/advise-tests-6DRSZMBL.js.map +1 -0
- package/dist/ai-G4MJWHTM.js +89 -0
- package/dist/ai-G4MJWHTM.js.map +1 -0
- package/dist/anonymize-QR6JGXA7.js +123 -0
- package/dist/anonymize-QR6JGXA7.js.map +1 -0
- package/dist/approval-YVHYTV53.js +73 -0
- package/dist/approval-YVHYTV53.js.map +1 -0
- package/dist/approval-chain-54KKJZS3.js +120 -0
- package/dist/approval-chain-54KKJZS3.js.map +1 -0
- package/dist/audit-log-QZFH7LUX.js +159 -0
- package/dist/audit-log-QZFH7LUX.js.map +1 -0
- package/dist/backlog-V2YUIQDL.js +76 -0
- package/dist/backlog-V2YUIQDL.js.map +1 -0
- package/dist/bisect-GEVYAVL5.js +111 -0
- package/dist/bisect-GEVYAVL5.js.map +1 -0
- package/dist/bookmarks-57LKS7P6.js +107 -0
- package/dist/bookmarks-57LKS7P6.js.map +1 -0
- package/dist/branch-W2MGMPSH.js +88 -0
- package/dist/branch-W2MGMPSH.js.map +1 -0
- package/dist/build-VNIQFKSP.js +23 -0
- package/dist/build-VNIQFKSP.js.map +1 -0
- package/dist/catalog-JLB5VCEV.js +137 -0
- package/dist/catalog-JLB5VCEV.js.map +1 -0
- package/dist/changelog-M7XGDYSY.js +220 -0
- package/dist/changelog-M7XGDYSY.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-EWXM4KJN.js +25 -0
- package/dist/chunk-EWXM4KJN.js.map +1 -0
- package/dist/chunk-JP2EZLR5.js +50 -0
- package/dist/chunk-JP2EZLR5.js.map +1 -0
- package/dist/chunk-VM2H4LAO.js +15 -0
- package/dist/chunk-VM2H4LAO.js.map +1 -0
- package/dist/chunk-ZWY4ZRHL.js +44 -0
- package/dist/chunk-ZWY4ZRHL.js.map +1 -0
- package/dist/cli.js +511 -19014
- package/dist/cli.js.map +1 -1
- package/dist/compare-5O6UTWPJ.js +405 -0
- package/dist/compare-5O6UTWPJ.js.map +1 -0
- package/dist/compare-profiles-7ZSNIW7B.js +218 -0
- package/dist/compare-profiles-7ZSNIW7B.js.map +1 -0
- package/dist/completion-I5U5VVAX.js +82 -0
- package/dist/completion-I5U5VVAX.js.map +1 -0
- package/dist/connection-GNTZDHXF.js +133 -0
- package/dist/connection-GNTZDHXF.js.map +1 -0
- package/dist/cost-estimate-TJDDH6TO.js +328 -0
- package/dist/cost-estimate-TJDDH6TO.js.map +1 -0
- package/dist/data-compare-UK2UXAS3.js +134 -0
- package/dist/data-compare-UK2UXAS3.js.map +1 -0
- package/dist/data-fit-Q45ENBRL.js +125 -0
- package/dist/data-fit-Q45ENBRL.js.map +1 -0
- package/dist/deploy-status-UUHKVDTI.js +58 -0
- package/dist/deploy-status-UUHKVDTI.js.map +1 -0
- package/dist/design-PO6UPBL7.js +138 -0
- package/dist/design-PO6UPBL7.js.map +1 -0
- package/dist/diagnose-6IFMELFR.js +145 -0
- package/dist/diagnose-6IFMELFR.js.map +1 -0
- package/dist/discover-A7OSZAHK.js +78 -0
- package/dist/discover-A7OSZAHK.js.map +1 -0
- package/dist/docs-CVRKGUSW.js +177 -0
- package/dist/docs-CVRKGUSW.js.map +1 -0
- package/dist/drift-XDA3BDYN.js +226 -0
- package/dist/drift-XDA3BDYN.js.map +1 -0
- package/dist/drift-gate-V7QSIOGZ.js +94 -0
- package/dist/drift-gate-V7QSIOGZ.js.map +1 -0
- package/dist/error-lookup-7ZWCZJ44.js +56 -0
- package/dist/error-lookup-7ZWCZJ44.js.map +1 -0
- package/dist/errorReporting-AQXKKGZH.js +109 -0
- package/dist/errorReporting-AQXKKGZH.js.map +1 -0
- package/dist/exec-PKBHLI7T.js +121 -0
- package/dist/exec-PKBHLI7T.js.map +1 -0
- package/dist/explain-LWKJOTL7.js +192 -0
- package/dist/explain-LWKJOTL7.js.map +1 -0
- package/dist/explorer-QOVM6VBD.js +61 -0
- package/dist/explorer-QOVM6VBD.js.map +1 -0
- package/dist/export-IYYBZ5HE.js +42 -0
- package/dist/export-IYYBZ5HE.js.map +1 -0
- package/dist/extract-VMMVRQVT.js +102 -0
- package/dist/extract-VMMVRQVT.js.map +1 -0
- package/dist/features-LE6BDZ2S.js +59 -0
- package/dist/features-LE6BDZ2S.js.map +1 -0
- package/dist/feedback-M7DM2EQC.js +161 -0
- package/dist/feedback-M7DM2EQC.js.map +1 -0
- package/dist/find-EME2JG2I.js +176 -0
- package/dist/find-EME2JG2I.js.map +1 -0
- package/dist/format-TRLWLMGS.js +141 -0
- package/dist/format-TRLWLMGS.js.map +1 -0
- package/dist/generate-6NAZGZDV.js +152 -0
- package/dist/generate-6NAZGZDV.js.map +1 -0
- package/dist/graph-QNQDAUO7.js +161 -0
- package/dist/graph-QNQDAUO7.js.map +1 -0
- package/dist/history-RONA7ZTI.js +199 -0
- package/dist/history-RONA7ZTI.js.map +1 -0
- package/dist/hosts-YBXY2ZG5.js +49 -0
- package/dist/hosts-YBXY2ZG5.js.map +1 -0
- package/dist/impact-T2JSANHS.js +59 -0
- package/dist/impact-T2JSANHS.js.map +1 -0
- package/dist/import-AELYLY6A.js +32 -0
- package/dist/import-AELYLY6A.js.map +1 -0
- package/dist/import-script-2OF5BI6A.js +83 -0
- package/dist/import-script-2OF5BI6A.js.map +1 -0
- package/dist/index.cjs +71 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +95 -31
- package/dist/index.js.map +1 -1
- package/dist/init-SWRRJMGI.js +57 -0
- package/dist/init-SWRRJMGI.js.map +1 -0
- package/dist/install-hooks-6SIAGTAF.js +109 -0
- package/dist/install-hooks-6SIAGTAF.js.map +1 -0
- package/dist/license-OAF22PLZ.js +46 -0
- package/dist/license-OAF22PLZ.js.map +1 -0
- package/dist/lineage-EW66XJ6O.js +552 -0
- package/dist/lineage-EW66XJ6O.js.map +1 -0
- package/dist/lint-FQ2OTYTQ.js +143 -0
- package/dist/lint-FQ2OTYTQ.js.map +1 -0
- package/dist/mcp-SARDMCDV.js +344 -0
- package/dist/mcp-SARDMCDV.js.map +1 -0
- package/dist/migrate-from-dbt-JVTXPWKQ.js +156 -0
- package/dist/migrate-from-dbt-JVTXPWKQ.js.map +1 -0
- package/dist/migrate-platform-NTRTOGNR.js +91 -0
- package/dist/migrate-platform-NTRTOGNR.js.map +1 -0
- package/dist/optimize-CJYWMAWA.js +105 -0
- package/dist/optimize-CJYWMAWA.js.map +1 -0
- package/dist/perf-LL2CPCJF.js +205 -0
- package/dist/perf-LL2CPCJF.js.map +1 -0
- package/dist/pii-FBDRDQ2E.js +136 -0
- package/dist/pii-FBDRDQ2E.js.map +1 -0
- package/dist/pilot-CCQERKPH.js +29 -0
- package/dist/pilot-CCQERKPH.js.map +1 -0
- package/dist/pr-comment-S5FF4QRX.js +79 -0
- package/dist/pr-comment-S5FF4QRX.js.map +1 -0
- package/dist/preview-5U4YVCRM.js +47 -0
- package/dist/preview-5U4YVCRM.js.map +1 -0
- package/dist/profile-7VC57KD2.js +101 -0
- package/dist/profile-7VC57KD2.js.map +1 -0
- package/dist/promote-AASEFTIA.js +408 -0
- package/dist/promote-AASEFTIA.js.map +1 -0
- package/dist/publish-UMVIWH6H.js +721 -0
- package/dist/publish-UMVIWH6H.js.map +1 -0
- package/dist/purge-QMXZKCMD.js +57 -0
- package/dist/purge-QMXZKCMD.js.map +1 -0
- package/dist/query-log-6OM4GI7W.js +112 -0
- package/dist/query-log-6OM4GI7W.js.map +1 -0
- package/dist/refactor-LTZQLJ35.js +5799 -0
- package/dist/refactor-LTZQLJ35.js.map +1 -0
- package/dist/refresh-4TY2AGOU.js +38 -0
- package/dist/refresh-4TY2AGOU.js.map +1 -0
- package/dist/replay-OOC25FZN.js +117 -0
- package/dist/replay-OOC25FZN.js.map +1 -0
- package/dist/revert-ODMUVJW6.js +110 -0
- package/dist/revert-ODMUVJW6.js.map +1 -0
- package/dist/review-XXPWOBFP.js +158 -0
- package/dist/review-XXPWOBFP.js.map +1 -0
- package/dist/rollback-suggest-6G2HEKFR.js +79 -0
- package/dist/rollback-suggest-6G2HEKFR.js.map +1 -0
- package/dist/safer-alternative-QFVNLG3L.js +89 -0
- package/dist/safer-alternative-QFVNLG3L.js.map +1 -0
- package/dist/safety-7QWRSUEZ.js +168 -0
- package/dist/safety-7QWRSUEZ.js.map +1 -0
- package/dist/savings-RHIXP6IT.js +95 -0
- package/dist/savings-RHIXP6IT.js.map +1 -0
- package/dist/scan-secrets-5YCQ4UCU.js +54 -0
- package/dist/scan-secrets-5YCQ4UCU.js.map +1 -0
- package/dist/schema-CIZXCQD2.js +429 -0
- package/dist/schema-CIZXCQD2.js.map +1 -0
- package/dist/script-K7CIN2P6.js +153 -0
- package/dist/script-K7CIN2P6.js.map +1 -0
- package/dist/search-BUZ5NXZZ.js +151 -0
- package/dist/search-BUZ5NXZZ.js.map +1 -0
- package/dist/seed-76QAK276.js +96 -0
- package/dist/seed-76QAK276.js.map +1 -0
- package/dist/sketch-PTLKDIK3.js +88 -0
- package/dist/sketch-PTLKDIK3.js.map +1 -0
- package/dist/snapshot-XLPR2OZ5.js +177 -0
- package/dist/snapshot-XLPR2OZ5.js.map +1 -0
- package/dist/snippets-EK4DK5CN.js +74 -0
- package/dist/snippets-EK4DK5CN.js.map +1 -0
- package/dist/standards-7T2UY6DD.js +241 -0
- package/dist/standards-7T2UY6DD.js.map +1 -0
- package/dist/suggest-VGRYSAR6.js +39 -0
- package/dist/suggest-VGRYSAR6.js.map +1 -0
- package/dist/suggest-constraints-MY5WKUHA.js +160 -0
- package/dist/suggest-constraints-MY5WKUHA.js.map +1 -0
- package/dist/suite-TRNGZWQM.js +88 -0
- package/dist/suite-TRNGZWQM.js.map +1 -0
- package/dist/telemetry-3U2QLA2S.js +75 -0
- package/dist/telemetry-3U2QLA2S.js.map +1 -0
- package/dist/template-ZERIXVXF.js +403 -0
- package/dist/template-ZERIXVXF.js.map +1 -0
- package/dist/test-5M2ED3WT.js +169 -0
- package/dist/test-5M2ED3WT.js.map +1 -0
- package/dist/trial-U732FONV.js +31 -0
- package/dist/trial-U732FONV.js.map +1 -0
- package/dist/validate-T6D2WCOK.js +106 -0
- package/dist/validate-T6D2WCOK.js.map +1 -0
- package/dist/verify-KXVASEEG.js +76 -0
- package/dist/verify-KXVASEEG.js.map +1 -0
- package/dist/watch-I6K4BNMA.js +80 -0
- package/dist/watch-I6K4BNMA.js.map +1 -0
- package/dist/xcompare-TPFLQO6W.js +87 -0
- package/dist/xcompare-TPFLQO6W.js.map +1 -0
- package/package.json +2 -2
- package/dist/cli.cjs +0 -19040
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.d.cts +0 -1
- package/dist/cli.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -18,7 +18,10 @@ var logger = {
|
|
|
18
18
|
// src/commands/init.ts
|
|
19
19
|
function initCommand() {
|
|
20
20
|
const cmd = new Command("init");
|
|
21
|
-
cmd.description("Initialize a new SDT project in the current directory.").option("--name <name>", "Project name", "NewSnowflakeProject").option("--scope <scope>", "Project scope: account | database | schema", "database").option("--db <database>", "Database name (required for database/schema scope)").option("--schema <schema>", "Schema name (required for schema scope)").option("--dir <dir>", "Target directory (default: cwd)", process.cwd()).
|
|
21
|
+
cmd.description("Initialize a new SDT project in the current directory.").option("--name <name>", "Project name", "NewSnowflakeProject").option("--scope <scope>", "Project scope: account | database | schema", "database").option("--db <database>", "Database name (required for database/schema scope)").option("--schema <schema>", "Schema name (required for schema scope)").option("--dir <dir>", "Target directory (default: cwd)", process.cwd()).option(
|
|
22
|
+
"--force",
|
|
23
|
+
"Overwrite an existing <name>.sdtproj in the target directory. Without this flag, init refuses to clobber an existing project file so a re-run never silently discards your project configuration."
|
|
24
|
+
).action(async (opts) => {
|
|
22
25
|
const scopeType = String(opts.scope);
|
|
23
26
|
if (!["account", "database", "schema"].includes(scopeType)) {
|
|
24
27
|
throw new Error(`Invalid --scope: ${opts.scope}. Use account | database | schema.`);
|
|
@@ -36,6 +39,15 @@ function initCommand() {
|
|
|
36
39
|
await fs.mkdir(root, { recursive: true });
|
|
37
40
|
const project10 = newProjectTemplate(String(opts.name), scope);
|
|
38
41
|
const projectPath = path.join(root, `${project10.name}.sdtproj`);
|
|
42
|
+
if (!opts.force) {
|
|
43
|
+
try {
|
|
44
|
+
await fs.access(projectPath);
|
|
45
|
+
logger.error(`${projectPath} already exists; pass --force to overwrite.`);
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
39
51
|
await saveProject(projectPath, project10);
|
|
40
52
|
const seedFolders = ["databases", "scripts/pre", "scripts/post"];
|
|
41
53
|
for (const f of seedFolders) await fs.mkdir(path.join(root, f), { recursive: true });
|
|
@@ -318,7 +330,13 @@ function compareCommand() {
|
|
|
318
330
|
const cmd = new Command4("compare");
|
|
319
331
|
cmd.description(
|
|
320
332
|
"Compare two schemas. Sources may be .sdtproj, .sdtpac, or snowflake://<profile>[/db[/schema]]."
|
|
321
|
-
).argument("
|
|
333
|
+
).argument("[source]", "Left side of the comparison (or use --source)").argument("[target]", "Right side of the comparison (or use --target)").option(
|
|
334
|
+
"--source <path>",
|
|
335
|
+
"Left side of the comparison (flag form of the positional source arg)"
|
|
336
|
+
).option(
|
|
337
|
+
"--target <path>",
|
|
338
|
+
"Right side of the comparison (flag form of the positional target arg)"
|
|
339
|
+
).option("-o, --output <path>", "Write JSON result to this path").option("--format <format>", "Output format: json | summary | markdown", "summary").option("--ignore-case", "Treat unquoted identifiers case-insensitively", false).option(
|
|
322
340
|
"--no-slice",
|
|
323
341
|
"Disable the source project's Slice (if it has one). Default: a project's slice is applied automatically."
|
|
324
342
|
).option(
|
|
@@ -343,7 +361,14 @@ function compareCommand() {
|
|
|
343
361
|
).option(
|
|
344
362
|
"--no-history",
|
|
345
363
|
"Skip writing the compare-history audit record (AUDITCMP.1). Default: every compare run writes a record to `.sdt/history/compare/`, exportable via `sdt audit-log emit`."
|
|
346
|
-
).action(async (
|
|
364
|
+
).action(async (sourceArgPos, targetArgPos, opts) => {
|
|
365
|
+
const sourceArg = opts.source ? String(opts.source) : sourceArgPos ? String(sourceArgPos) : "";
|
|
366
|
+
const targetArg = opts.target ? String(opts.target) : targetArgPos ? String(targetArgPos) : "";
|
|
367
|
+
if (!sourceArg || !targetArg) {
|
|
368
|
+
throw new Error(
|
|
369
|
+
"compare needs a source and a target \u2014 pass them positionally (`sdt compare <source> <target>`) or via `--source`/`--target`."
|
|
370
|
+
);
|
|
371
|
+
}
|
|
347
372
|
const nameMapping = await buildMappingFromOptions(opts);
|
|
348
373
|
const source = await resolveSource(String(sourceArg));
|
|
349
374
|
const target = await resolveSource(String(targetArg));
|
|
@@ -653,11 +678,14 @@ function splitStatements(sql) {
|
|
|
653
678
|
function publishCommand() {
|
|
654
679
|
const cmd = new Command5("publish");
|
|
655
680
|
cmd.description(
|
|
656
|
-
"Compare a .sdtpac to a live Snowflake target and apply (or dry-run) the migration."
|
|
681
|
+
"Compare a .sdtpac (the desired state) to a live Snowflake target and apply (or dry-run) the migration. Shared form with `ddt publish`: `--source <desired> --connection <live-target>`."
|
|
682
|
+
).option(
|
|
683
|
+
"--source <path>",
|
|
684
|
+
"Path to the desired-state .sdtpac (canonical name; the same flag `ddt publish` uses). Required for a normal publish; omit only with --restore-from-snapshot."
|
|
657
685
|
).option(
|
|
658
686
|
"--pac <path>",
|
|
659
|
-
"
|
|
660
|
-
).requiredOption("-c, --connection <profile>", "Connection profile name").option(
|
|
687
|
+
"Back-compat alias for --source (the desired-state .sdtpac). Prefer --source for cross-platform parity with `ddt publish`."
|
|
688
|
+
).requiredOption("-c, --connection <profile>", "Connection profile name (the live target).").option(
|
|
661
689
|
"--restore-from-snapshot <batchId>",
|
|
662
690
|
"Recovery mode: skip the compare step and emit ALTER TABLE \u2026 SWAP WITH against the snapshot batch <batchId> from the registry. Dry-run by default; pass --apply --yes to execute. This is the command printed by TRUST.4's post-deploy-smoke + TRUST.8's restore-hint when a deploy fails \u2014 they tell the operator to run `sdt publish --restore-from-snapshot <id>`."
|
|
663
691
|
).option(
|
|
@@ -744,12 +772,15 @@ function publishCommand() {
|
|
|
744
772
|
await runRestoreFromSnapshot(opts);
|
|
745
773
|
return;
|
|
746
774
|
}
|
|
747
|
-
|
|
748
|
-
|
|
775
|
+
const pacRef = opts.source ?? opts.pac;
|
|
776
|
+
if (!pacRef) {
|
|
777
|
+
logger.error(
|
|
778
|
+
"--source <path> (or its alias --pac) is required (unless --restore-from-snapshot is given)."
|
|
779
|
+
);
|
|
749
780
|
process.exitCode = 1;
|
|
750
781
|
return;
|
|
751
782
|
}
|
|
752
|
-
const pacPath = path4.resolve(String(
|
|
783
|
+
const pacPath = path4.resolve(String(pacRef));
|
|
753
784
|
const pac10 = await readPac(pacPath);
|
|
754
785
|
const freshnessMode = opts.freshness ?? "warn";
|
|
755
786
|
if (freshnessMode !== "skip") {
|
|
@@ -1512,7 +1543,12 @@ function driftCommand() {
|
|
|
1512
1543
|
import { promises as fs6 } from "fs";
|
|
1513
1544
|
import path6 from "path";
|
|
1514
1545
|
import { Command as Command7 } from "commander";
|
|
1515
|
-
import {
|
|
1546
|
+
import {
|
|
1547
|
+
catalog as catalog2,
|
|
1548
|
+
project,
|
|
1549
|
+
validate as validateNs,
|
|
1550
|
+
variables as variablesNs
|
|
1551
|
+
} from "@sdt-tools/core";
|
|
1516
1552
|
function validateCommand() {
|
|
1517
1553
|
const cmd = new Command7("validate");
|
|
1518
1554
|
cmd.description(
|
|
@@ -1541,12 +1577,17 @@ function validateCommand() {
|
|
|
1541
1577
|
logger.dim(` Profiles: ${Object.keys(loaded.project.deploymentProfiles ?? {}).length}`);
|
|
1542
1578
|
if (opts.checkVariables) {
|
|
1543
1579
|
const projRoot = path6.dirname(path6.resolve(String(opts.project)));
|
|
1544
|
-
const
|
|
1545
|
-
files
|
|
1580
|
+
const { results } = await catalog2.mapPool(
|
|
1581
|
+
files,
|
|
1582
|
+
async (f) => {
|
|
1546
1583
|
const relPath = path6.relative(projRoot, f).split(path6.sep).join("/");
|
|
1547
1584
|
const content = await fs6.readFile(f, "utf8");
|
|
1548
1585
|
return { path: relPath, content };
|
|
1549
|
-
}
|
|
1586
|
+
},
|
|
1587
|
+
{ concurrency: 16, stopOnError: true }
|
|
1588
|
+
);
|
|
1589
|
+
const fileContents = results.filter(
|
|
1590
|
+
(r) => r !== void 0
|
|
1550
1591
|
);
|
|
1551
1592
|
const profilesBlock = loaded.project.deploymentProfiles ?? {};
|
|
1552
1593
|
const profileVariableKeys = Object.values(profilesBlock).map(
|
|
@@ -1677,6 +1718,11 @@ function connectionCommand() {
|
|
|
1677
1718
|
await upsertProfile(profile);
|
|
1678
1719
|
logger.success(`Saved profile "${profile.name}".`);
|
|
1679
1720
|
});
|
|
1721
|
+
cmd.command("get <name>").description("Print a profile (secrets are redacted).").action(async (name) => {
|
|
1722
|
+
const profile = await getProfile5(String(name));
|
|
1723
|
+
const redacted = { ...profile, auth: redactAuth(profile.auth) };
|
|
1724
|
+
logger.info(JSON.stringify(redacted, null, 2));
|
|
1725
|
+
});
|
|
1680
1726
|
cmd.command("remove").description("Remove a connection profile.").argument("<name>").action(async (name) => {
|
|
1681
1727
|
const ok = await removeProfile(String(name));
|
|
1682
1728
|
if (ok) logger.success(`Removed profile "${name}".`);
|
|
@@ -1694,6 +1740,24 @@ function connectionCommand() {
|
|
|
1694
1740
|
});
|
|
1695
1741
|
return cmd;
|
|
1696
1742
|
}
|
|
1743
|
+
function redactAuth(auth) {
|
|
1744
|
+
const isPlaceholder = (v) => v.startsWith("env:") || v.startsWith("keyring:");
|
|
1745
|
+
switch (auth.method) {
|
|
1746
|
+
case "PASSWORD":
|
|
1747
|
+
case "MFA":
|
|
1748
|
+
return auth.password && !isPlaceholder(auth.password) ? { ...auth, password: "<redacted>" } : auth;
|
|
1749
|
+
case "OAUTH":
|
|
1750
|
+
return auth.token && !isPlaceholder(auth.token) ? { ...auth, token: "<redacted>" } : auth;
|
|
1751
|
+
case "KEY_PAIR":
|
|
1752
|
+
return auth.privateKeyPassphrase && !isPlaceholder(auth.privateKeyPassphrase) ? { ...auth, privateKeyPassphrase: "<redacted>" } : auth;
|
|
1753
|
+
case "EXTERNAL_BROWSER":
|
|
1754
|
+
return auth;
|
|
1755
|
+
default: {
|
|
1756
|
+
const _exhaustive = auth;
|
|
1757
|
+
return _exhaustive;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1697
1761
|
|
|
1698
1762
|
// src/commands/scaffold.ts
|
|
1699
1763
|
import { Command as Command9 } from "commander";
|
|
@@ -4690,7 +4754,7 @@ async function readStdin() {
|
|
|
4690
4754
|
// src/commands/compare-profiles.ts
|
|
4691
4755
|
import { promises as fs23 } from "fs";
|
|
4692
4756
|
import { Command as Command28 } from "commander";
|
|
4693
|
-
import { catalog as
|
|
4757
|
+
import { catalog as catalog3, compareProfiles, pac as pac9, project as project9 } from "@sdt-tools/core";
|
|
4694
4758
|
function compareProfilesCommand() {
|
|
4695
4759
|
const cmd = new Command28("compare-profiles");
|
|
4696
4760
|
cmd.description("Manage saved compare profiles (.sdt/compare-profiles.json).");
|
|
@@ -4839,7 +4903,7 @@ function compareProfilesCommand() {
|
|
|
4839
4903
|
}
|
|
4840
4904
|
async function resolveEndpointFqns(endpoint, root) {
|
|
4841
4905
|
if (endpoint.kind === "connection") {
|
|
4842
|
-
const cache = new
|
|
4906
|
+
const cache = new catalog3.CatalogCache({ root, connection: endpoint.reference });
|
|
4843
4907
|
const snapshot = await cache.get();
|
|
4844
4908
|
if (snapshot.databases.length === 0) {
|
|
4845
4909
|
return {
|
|
@@ -4899,7 +4963,7 @@ async function readStdin2() {
|
|
|
4899
4963
|
|
|
4900
4964
|
// src/commands/explorer.ts
|
|
4901
4965
|
import { Command as Command29 } from "commander";
|
|
4902
|
-
import { catalog as
|
|
4966
|
+
import { catalog as catalog4, objectExplorer } from "@sdt-tools/core";
|
|
4903
4967
|
function explorerCommand() {
|
|
4904
4968
|
const cmd = new Command29("explorer");
|
|
4905
4969
|
cmd.description(
|
|
@@ -4909,7 +4973,7 @@ function explorerCommand() {
|
|
|
4909
4973
|
"Truncate tree at depth N (0 = root only, 1 = +databases, 2 = +schemas, 3 = +object-groups, 4 = +objects). Default unlimited.",
|
|
4910
4974
|
(v) => parseInt(v, 10)
|
|
4911
4975
|
).option("--json", "Emit tree as JSON instead of ASCII.").action(async (opts) => {
|
|
4912
|
-
const cache = new
|
|
4976
|
+
const cache = new catalog4.CatalogCache({
|
|
4913
4977
|
root: String(opts.root),
|
|
4914
4978
|
connection: String(opts.connection)
|
|
4915
4979
|
});
|
|
@@ -4952,7 +5016,7 @@ function renderChild(node, prefix, isLast) {
|
|
|
4952
5016
|
|
|
4953
5017
|
// src/commands/catalog.ts
|
|
4954
5018
|
import { Command as Command30 } from "commander";
|
|
4955
|
-
import { catalog as
|
|
5019
|
+
import { catalog as catalog5 } from "@sdt-tools/core";
|
|
4956
5020
|
import { getProfile as getProfile9, SnowflakeConnection as SnowflakeConnection9 } from "@sdt-tools/core/connection";
|
|
4957
5021
|
var BUILTIN_DATABASES = /* @__PURE__ */ new Set(["SNOWFLAKE", "SNOWFLAKE_SAMPLE_DATA", "UTIL_DB"]);
|
|
4958
5022
|
function catalogCommand() {
|
|
@@ -4967,7 +5031,7 @@ function catalogCommand() {
|
|
|
4967
5031
|
).option("--no-fingerprint-skip", "Force a full scan even when fingerprints are unchanged.").action(async (opts) => {
|
|
4968
5032
|
const profile = await getProfile9(String(opts.connection));
|
|
4969
5033
|
const conn = new SnowflakeConnection9(profile);
|
|
4970
|
-
const cache = new
|
|
5034
|
+
const cache = new catalog5.CatalogCache({
|
|
4971
5035
|
root: String(opts.root),
|
|
4972
5036
|
connection: profile.name
|
|
4973
5037
|
});
|
|
@@ -4986,27 +5050,27 @@ function catalogCommand() {
|
|
|
4986
5050
|
const cachedByDb = new Map(cached.databases.map((d) => [d.database, d]));
|
|
4987
5051
|
const concurrency = Math.max(1, Number(opts.concurrency) || 10);
|
|
4988
5052
|
const fingerprintSkip = opts.fingerprintSkip !== false;
|
|
4989
|
-
const { results, errors } = await
|
|
5053
|
+
const { results, errors } = await catalog5.mapPool(
|
|
4990
5054
|
dbs,
|
|
4991
5055
|
async (db) => {
|
|
4992
5056
|
let freshFingerprint = null;
|
|
4993
5057
|
try {
|
|
4994
5058
|
const fpRes = await conn.query(
|
|
4995
|
-
|
|
5059
|
+
catalog5.fingerprintSqlForDatabase(db)
|
|
4996
5060
|
);
|
|
4997
|
-
freshFingerprint =
|
|
5061
|
+
freshFingerprint = catalog5.parseFingerprintRow(fpRes.rows);
|
|
4998
5062
|
} catch (err) {
|
|
4999
5063
|
logger.warn(
|
|
5000
5064
|
`fingerprint(${db}) failed; falling through to full scan: ${err.message}`
|
|
5001
5065
|
);
|
|
5002
5066
|
}
|
|
5003
5067
|
const cachedDb = cachedByDb.get(db);
|
|
5004
|
-
if (fingerprintSkip && cachedDb && cachedDb.fingerprint != null && freshFingerprint != null &&
|
|
5068
|
+
if (fingerprintSkip && cachedDb && cachedDb.fingerprint != null && freshFingerprint != null && catalog5.isFresh(cachedDb.fingerprint, freshFingerprint)) {
|
|
5005
5069
|
logger.dim(` ${db}: fresh; reusing cache`);
|
|
5006
5070
|
return { database: db, fingerprint: cachedDb.fingerprint, schemas: cachedDb.schemas };
|
|
5007
5071
|
}
|
|
5008
|
-
const scanRes = await conn.query(
|
|
5009
|
-
const schemas =
|
|
5072
|
+
const scanRes = await conn.query(catalog5.bulkScanSqlForDatabase(db));
|
|
5073
|
+
const schemas = catalog5.parseBulkScanRows(db, scanRes.rows);
|
|
5010
5074
|
const fingerprint = freshFingerprint ?? null;
|
|
5011
5075
|
logger.dim(
|
|
5012
5076
|
` ${db}: ${schemas.length} schemas / ${schemas.reduce((sum, s) => sum + s.objects.length, 0)} objects`
|
|
@@ -5018,8 +5082,8 @@ function catalogCommand() {
|
|
|
5018
5082
|
for (const e of errors) {
|
|
5019
5083
|
logger.warn(`scan failed for "${dbs[e.index]}": ${e.error.message}`);
|
|
5020
5084
|
}
|
|
5021
|
-
const snapshot =
|
|
5022
|
-
version:
|
|
5085
|
+
const snapshot = catalog5.refreshFingerprints({
|
|
5086
|
+
version: catalog5.CATALOG_SNAPSHOT_VERSION,
|
|
5023
5087
|
connection: profile.name,
|
|
5024
5088
|
snapshotAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5025
5089
|
fingerprint: null,
|
|
@@ -5032,7 +5096,7 @@ function catalogCommand() {
|
|
|
5032
5096
|
}
|
|
5033
5097
|
});
|
|
5034
5098
|
cmd.command("show").description("Pretty-print or JSON-dump the cached snapshot for a connection.").requiredOption("-c, --connection <name>", "Connection profile name.").option("--root <path>", "Project root. Default cwd.", process.cwd()).option("--json", "Emit JSON instead of summary.").action(async (opts) => {
|
|
5035
|
-
const cache = new
|
|
5099
|
+
const cache = new catalog5.CatalogCache({
|
|
5036
5100
|
root: String(opts.root),
|
|
5037
5101
|
connection: String(opts.connection)
|
|
5038
5102
|
});
|
|
@@ -5059,7 +5123,7 @@ function catalogCommand() {
|
|
|
5059
5123
|
}
|
|
5060
5124
|
});
|
|
5061
5125
|
cmd.command("clear").description("Delete the cached snapshot for a connection.").requiredOption("-c, --connection <name>", "Connection profile name.").option("--root <path>", "Project root. Default cwd.", process.cwd()).action(async (opts) => {
|
|
5062
|
-
const cache = new
|
|
5126
|
+
const cache = new catalog5.CatalogCache({
|
|
5063
5127
|
root: String(opts.root),
|
|
5064
5128
|
connection: String(opts.connection)
|
|
5065
5129
|
});
|
|
@@ -5200,7 +5264,7 @@ import { Command as Command32 } from "commander";
|
|
|
5200
5264
|
import { promises as fs25 } from "fs";
|
|
5201
5265
|
import os from "os";
|
|
5202
5266
|
import path20 from "path";
|
|
5203
|
-
import { catalog as
|
|
5267
|
+
import { catalog as catalog6 } from "@sdt-tools/core";
|
|
5204
5268
|
function buildDriftReport(results) {
|
|
5205
5269
|
const allFqns = /* @__PURE__ */ new Set();
|
|
5206
5270
|
const byFqn = /* @__PURE__ */ new Map();
|
|
@@ -5263,7 +5327,7 @@ async function loadProfileNames(profilesOpt, profilesDir) {
|
|
|
5263
5327
|
}
|
|
5264
5328
|
async function defaultSearchFn(profile, pattern, opts) {
|
|
5265
5329
|
const root = opts.root ?? process.cwd();
|
|
5266
|
-
const cache = new
|
|
5330
|
+
const cache = new catalog6.CatalogCache({ root, connection: profile });
|
|
5267
5331
|
const snapshot = await cache.get();
|
|
5268
5332
|
if (snapshot.databases.length === 0) {
|
|
5269
5333
|
throw new Error(
|