@happyvertical/smrt-cli 0.54.4 → 0.55.1

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.
Files changed (25) hide show
  1. package/dist/{AuditLogCollection-WDHL-_AF-Cm6c206j.js → AuditLogCollection-WDHL-_AF-G2UOSM3H.js} +1 -1
  2. package/dist/{OidcIdentity-BjRu3n1g-DPfoJOJq.js → OidcIdentity-BjRu3n1g-CzvSN6Wz.js} +2 -2
  3. package/dist/{OidcIdentityCollection-B4jYh36_-CDCS-lBk.js → OidcIdentityCollection-B4jYh36_-6UWtXCwi.js} +1 -1
  4. package/dist/{ProfileAssetCollection-HeMtjBc0-BnvWWbZ6.js → ProfileAssetCollection-HeMtjBc0-Cz4MOeSB.js} +3 -3
  5. package/dist/{ProfileCollection-Bt6IJK49-ir8YINdu.js → ProfileCollection-Bt6IJK49-CFyOiVFz.js} +16 -16
  6. package/dist/{ProfileLinkCollection-u1hhzKTm-DN7eng_7.js → ProfileLinkCollection-u1hhzKTm-CAfIjZ4f.js} +2 -2
  7. package/dist/{ProfileMetadataCollection-BIYKy4Y3-BUDJszIc.js → ProfileMetadataCollection-BIYKy4Y3-CqcaAHAJ.js} +1 -1
  8. package/dist/{ProfileMetafieldCollection-Buz7gzag-DDlih_5j.js → ProfileMetafieldCollection-Buz7gzag-BNRo6e4x.js} +1 -1
  9. package/dist/{ProfileRelationshipCollection-C4g_QLI4-QJJ__ROk.js → ProfileRelationshipCollection-C4g_QLI4-DeJzJ_hF.js} +1 -1
  10. package/dist/cli-generator.d.ts.map +1 -1
  11. package/dist/commands/db-command-utils.d.ts +8 -14
  12. package/dist/commands/db-command-utils.d.ts.map +1 -1
  13. package/dist/commands/utilities.d.ts.map +1 -1
  14. package/dist/{commands-iFti-f80.js → commands-CboMy2vr.js} +62 -123
  15. package/dist/db-command-utils-Cn8tjy7N.js +40 -0
  16. package/dist/dist-CkONQFUR.js +20 -0
  17. package/dist/{dist-DIGbZpp6.js → dist-F98s-wG1.js} +4 -4
  18. package/dist/{dist-DJOzoOZn.js → dist-N7UoPf_4.js} +3 -3
  19. package/dist/{dist-D5GdZ8W6.js → dist-m9bKxs6w.js} +15 -15
  20. package/dist/{dist-Bqg09MUx.js → dist-wrk3GKo3.js} +2 -2
  21. package/dist/index.js +13 -10
  22. package/dist/{oidcProvisioningPrimitives-CYood-2M-D8npRnlS.js → oidcProvisioningPrimitives-CYood-2M-DKUWB1oI.js} +3 -3
  23. package/dist/{resolveIdentity-CvGDegU6-DkEz2oV8.js → resolveIdentity-CvGDegU6-BePPF1Iv.js} +14 -14
  24. package/package.json +10 -10
  25. package/dist/dist-CrzK6GwA.js +0 -20
@@ -1,4 +1,5 @@
1
1
  import { t as resolveManifestEntryPackageName } from "./index.js";
2
+ import { a as redactDatabaseUrlsInText, i as quoteIdentifier, r as formatDatabaseDisplayUrl, t as closeDatabaseConnection } from "./db-command-utils-Cn8tjy7N.js";
2
3
  import { t as DEFAULT_CLI_CONFIG } from "./config-hqNo4lzH.js";
3
4
  import { addMcpAppsRuntime, assertMcpAppsPluginName, configureMcpAppsConsumerRegistry, mcpAppsCommands, scaffoldMcpAppsPackage, validateMcpAppsPackage } from "./mcp-apps-packaging-CixRnxz_.js";
4
5
  import { createRequire } from "node:module";
@@ -27,68 +28,6 @@ import { renderForeignKeyAddStatements } from "@happyvertical/smrt-core/schema";
27
28
  import { FRAMEWORK_BASE_TABLE_NAMES, backfillLegacyQualifiedNames, buildIntegerWidthTableStatements, collectIntegerWidthTargets, collectNullEqualIndexTargets, countLegacyQualifiedNameReferences, dropFrameworkBaseTables, migrateNullEqualIndexes, nullEqualIndexStatements, parsePostgresTimeoutMs, planFrameworkBaseTableDrop, preflightIntegerWidthWidening, preflightNullEqualIndexes, widenIntegerColumnsToBigInt } from "@happyvertical/smrt-core/migrations";
28
29
  import { buildArchitectureContext, buildKnowledgeIndex, buildReviewContext, checkKnowledgeFreshness, compactContextResult, diffKnowledgeIndex, renderFreshnessResult, renderKnowledgeIndexMarkdown } from "@happyvertical/smrt-dev-mcp/knowledge";
29
30
  import { RUNTIME_TOOLS } from "@happyvertical/smrt-dev-mcp/runtime";
30
- //#region src/commands/db-command-utils.ts
31
- var SENSITIVE_QUERY_PARAMS = /* @__PURE__ */ new Set([
32
- "access_token",
33
- "apikey",
34
- "api_key",
35
- "auth",
36
- "auth_token",
37
- "password",
38
- "token"
39
- ]);
40
- var CONNECTION_STRING_USERINFO_PATTERN = /([a-z][a-z0-9+.-]*:\/\/[^:\s/@]*:)[^\n]*@/gi;
41
- var SENSITIVE_QUERY_PARAM_PATTERN = /([?&](?:access_token|apikey|api_key|auth|auth_token|password|token)=)[^&\s]+/gi;
42
- function redactConnectionString(value) {
43
- let redacted = value;
44
- try {
45
- const url = new URL(value);
46
- if (url.password) url.password = "***";
47
- for (const key of [...url.searchParams.keys()]) if (SENSITIVE_QUERY_PARAMS.has(key.toLowerCase())) url.searchParams.set(key, "***");
48
- redacted = url.toString();
49
- } catch {
50
- redacted = value.replace(CONNECTION_STRING_USERINFO_PATTERN, "$1***@");
51
- }
52
- return redacted.replace(SENSITIVE_QUERY_PARAM_PATTERN, "$1***");
53
- }
54
- /**
55
- * Redact connection-string credentials embedded anywhere inside arbitrary
56
- * text, rather than a standalone URL value.
57
- *
58
- * Command failure paths surface driver/error text (`error.message`,
59
- * `error.stack`, wrapped `originalError`/`sql` context) that can itself
60
- * contain the connection string a command was given — for example a
61
- * malformed-URL parse error, or a client library that echoes the DSN it
62
- * tried. `redactConnectionString` expects its whole input to parse as a URL;
63
- * this scrubs matches wherever they occur in a larger, unknown-shaped string
64
- * and never throws.
65
- */
66
- function redactConnectionStringsInText(text) {
67
- if (!text) return text;
68
- return text.replace(CONNECTION_STRING_USERINFO_PATTERN, "$1***@").replace(SENSITIVE_QUERY_PARAM_PATTERN, "$1***");
69
- }
70
- /**
71
- * Quote a SQL identifier (table name, column name, etc.).
72
- *
73
- * Uses double quotes, the ANSI SQL standard understood by SQLite, PostgreSQL,
74
- * and DuckDB, and escapes embedded double quotes by doubling them.
75
- */
76
- function quoteIdentifier(name) {
77
- return `"${name.replace(/"/g, "\"\"")}"`;
78
- }
79
- function formatDatabaseDisplayUrl(dbType, dbUrl) {
80
- return redactConnectionString(/^[a-z][a-z0-9+.-]*:\/\//i.test(dbUrl) ? dbUrl : `${dbType}://${dbUrl}`);
81
- }
82
- async function closeDatabaseConnection(db) {
83
- if (!db || typeof db !== "object") return;
84
- const closeable = db;
85
- const close = closeable.close ?? closeable.client?.end ?? closeable.client?.close;
86
- if (typeof close !== "function") return;
87
- try {
88
- await close.call(closeable.close ? closeable : closeable.client);
89
- } catch {}
90
- }
91
- //#endregion
92
31
  //#region src/commands/config-export.ts
93
32
  /**
94
33
  * config:export Command
@@ -223,10 +162,10 @@ var configExportCommand = {
223
162
  console.log(" };");
224
163
  console.log("");
225
164
  } catch (error) {
226
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
165
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
227
166
  else {
228
167
  console.error("\n❌ Failed to export configuration:");
229
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
168
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
230
169
  }
231
170
  process.exitCode = 1;
232
171
  return;
@@ -1447,10 +1386,10 @@ var dbDiffCommand = {
1447
1386
  console.log("\n💡 Schema migrations are manifest-driven.");
1448
1387
  console.log(" Update @smrt object definitions, then run smrt db:migrate.\n");
1449
1388
  } catch (error) {
1450
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
1389
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
1451
1390
  else {
1452
1391
  console.error("\n❌ Failed to generate diff:");
1453
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
1392
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
1454
1393
  }
1455
1394
  process.exitCode = 1;
1456
1395
  return;
@@ -1662,7 +1601,7 @@ var dbHistoryCommand = {
1662
1601
  const annotatedHistory = history.map((row) => {
1663
1602
  const m = {
1664
1603
  ...row,
1665
- error_message: row.error_message ? redactConnectionStringsInText(row.error_message) : row.error_message
1604
+ error_message: row.error_message ? redactDatabaseUrlsInText(row.error_message) : row.error_message
1666
1605
  };
1667
1606
  if (m.status !== "failed") return {
1668
1607
  ...m,
@@ -1762,10 +1701,10 @@ var dbHistoryCommand = {
1762
1701
  console.log(" smrt db:rollback - Rollback migrations");
1763
1702
  console.log();
1764
1703
  } catch (error) {
1765
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
1704
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
1766
1705
  else {
1767
1706
  console.error("\n❌ Failed to get migration history:");
1768
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
1707
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
1769
1708
  }
1770
1709
  process.exitCode = 1;
1771
1710
  return;
@@ -1828,7 +1767,7 @@ function redactOrphanReport(report) {
1828
1767
  ...report,
1829
1768
  skipped: report.skipped.map((skip) => ({
1830
1769
  ...skip,
1831
- reason: redactConnectionStringsInText(skip.reason)
1770
+ reason: redactDatabaseUrlsInText(skip.reason)
1832
1771
  }))
1833
1772
  };
1834
1773
  }
@@ -1919,10 +1858,10 @@ var dbOrphansCommand = {
1919
1858
  for (const line of formatOrphanReport(report, { verbose: options.verbose })) console.log(line);
1920
1859
  console.log();
1921
1860
  } catch (error) {
1922
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
1861
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
1923
1862
  else {
1924
1863
  console.error("\n❌ Failed to collect the orphan report:");
1925
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
1864
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
1926
1865
  }
1927
1866
  process.exitCode = 1;
1928
1867
  } finally {
@@ -2124,7 +2063,7 @@ function redactSweepResult(result) {
2124
2063
  ...result,
2125
2064
  tasks: result.tasks.map((task) => task.error ? {
2126
2065
  ...task,
2127
- error: redactConnectionStringsInText(task.error)
2066
+ error: redactDatabaseUrlsInText(task.error)
2128
2067
  } : task)
2129
2068
  };
2130
2069
  }
@@ -2225,7 +2164,7 @@ var dbPruneCommand = {
2225
2164
  }
2226
2165
  if (result.failed) process.exitCode = 1;
2227
2166
  } catch (error) {
2228
- const message = redactConnectionStringsInText(error instanceof Error ? error.message : String(error));
2167
+ const message = redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error));
2229
2168
  if (options.json) console.log(JSON.stringify({ error: message }));
2230
2169
  else console.error(`\n❌ Retention sweep failed: ${message}\n`);
2231
2170
  process.exitCode = 1;
@@ -2512,7 +2451,7 @@ var dbRollbackCommand = {
2512
2451
  successCount++;
2513
2452
  } catch (error) {
2514
2453
  errorCount++;
2515
- const errorMsg = redactConnectionStringsInText(error instanceof Error ? error.message : String(error));
2454
+ const errorMsg = redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error));
2516
2455
  if (!options.json) console.error(` ✗ ${migration.name} failed: ${errorMsg}`);
2517
2456
  results.push({
2518
2457
  name: migration.name,
@@ -2520,7 +2459,7 @@ var dbRollbackCommand = {
2520
2459
  error: errorMsg
2521
2460
  });
2522
2461
  stoppedBy = migration.name;
2523
- if (options.verbose && error instanceof Error && error.stack) console.error(`\n${redactConnectionStringsInText(error.stack)}\n`);
2462
+ if (options.verbose && error instanceof Error && error.stack) console.error(`\n${redactDatabaseUrlsInText(error.stack)}\n`);
2524
2463
  }
2525
2464
  }
2526
2465
  if (options.json) console.log(JSON.stringify({
@@ -2543,10 +2482,10 @@ var dbRollbackCommand = {
2543
2482
  }
2544
2483
  if (errorCount > 0) process.exitCode = 1;
2545
2484
  } catch (error) {
2546
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
2485
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
2547
2486
  else {
2548
2487
  console.error("\n❌ Rollback failed:");
2549
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
2488
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
2550
2489
  }
2551
2490
  process.exitCode = 1;
2552
2491
  return;
@@ -2658,7 +2597,7 @@ async function runLiveSchemaParity(options = {}) {
2658
2597
  return {
2659
2598
  report: null,
2660
2599
  database: null,
2661
- error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error))
2600
+ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))
2662
2601
  };
2663
2602
  } finally {
2664
2603
  await closeDatabaseConnection(db);
@@ -3311,7 +3250,7 @@ var dbStatusCommand = {
3311
3250
  const applied = await tracker.getAppliedMigrations();
3312
3251
  const failed = (await tracker.getHistory({ status: "failed" })).map((row) => row.error_message ? {
3313
3252
  ...row,
3314
- error_message: redactConnectionStringsInText(row.error_message)
3253
+ error_message: redactDatabaseUrlsInText(row.error_message)
3315
3254
  } : row);
3316
3255
  const { discovered, totalObjects } = await autoDiscoverAndLoad();
3317
3256
  const schemaContract = await evaluateSchemaContract({
@@ -3396,7 +3335,7 @@ var dbStatusCommand = {
3396
3335
  engineHint: dbType
3397
3336
  });
3398
3337
  } catch (error) {
3399
- status.parityError = redactConnectionStringsInText(error instanceof Error ? error.message : String(error));
3338
+ status.parityError = redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error));
3400
3339
  }
3401
3340
  } else if (options.parity) status.parityError = "The configured database adapter cannot describe tables, so live-schema parity cannot be verified.";
3402
3341
  try {
@@ -3407,10 +3346,10 @@ var dbStatusCommand = {
3407
3346
  status.orphanedForeignKeys = affectedOrphanCounts(orphanReport);
3408
3347
  status.orphanProbeFailures = orphanReport.skipped.filter((skip) => skip.kind === "probe_failed").map((skip) => ({
3409
3348
  ...skip,
3410
- reason: redactConnectionStringsInText(skip.reason)
3349
+ reason: redactDatabaseUrlsInText(skip.reason)
3411
3350
  }));
3412
3351
  } catch (error) {
3413
- status.orphansError = redactConnectionStringsInText(error instanceof Error ? error.message : String(error));
3352
+ status.orphansError = redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error));
3414
3353
  }
3415
3354
  const failedAssessments = assessFailedMigrations(failed, typeof db.getTableSchema === "function" ? diff : null);
3416
3355
  status.migrations.failed = {
@@ -3540,10 +3479,10 @@ var dbStatusCommand = {
3540
3479
  console.log(" smrt db:diff - Show schema differences");
3541
3480
  console.log();
3542
3481
  } catch (error) {
3543
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
3482
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
3544
3483
  else {
3545
3484
  console.error("\n❌ Failed to get migration status:");
3546
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
3485
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
3547
3486
  }
3548
3487
  process.exitCode = 1;
3549
3488
  return;
@@ -4628,12 +4567,12 @@ var exportCommand = {
4628
4567
  if (showDrafts) console.log(" Mode: Including drafts");
4629
4568
  }
4630
4569
  } catch (error) {
4631
- if (options.json) console.log(JSON.stringify({ error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)) }));
4570
+ if (options.json) console.log(JSON.stringify({ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)) }));
4632
4571
  else {
4633
4572
  console.error("\n❌ Export failed:");
4634
4573
  if (error instanceof Error) {
4635
- console.error(` ${redactConnectionStringsInText(error.message)}`);
4636
- if (options.verbose && error.stack) console.error(redactConnectionStringsInText(error.stack));
4574
+ console.error(` ${redactDatabaseUrlsInText(error.message)}`);
4575
+ if (options.verbose && error.stack) console.error(redactDatabaseUrlsInText(error.stack));
4637
4576
  }
4638
4577
  }
4639
4578
  process.exitCode = 1;
@@ -7069,7 +7008,7 @@ var dbDropFrameworkBaseTablesCommand = {
7069
7008
  });
7070
7009
  console.log(`\n✓ Dropped ${result.droppedTables.length} table(s) and ${result.droppedIndexes.length} companion index(es): ${result.droppedTables.map((table) => quoteIdentifier(table)).join(", ")}\n`);
7071
7010
  } catch (error) {
7072
- console.error(`\n❌ Framework base-table remediation failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
7011
+ console.error(`\n❌ Framework base-table remediation failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
7073
7012
  process.exitCode = 1;
7074
7013
  } finally {
7075
7014
  await closeDatabaseConnection(db);
@@ -7112,7 +7051,7 @@ var dbMaterializeTenantHierarchyCommand = {
7112
7051
  if (!config.database?.url || config.database.url === ":memory:") throw new Error("Database configuration required for db:materialize-tenant-hierarchy. Configure database.url in smrt.config.ts (or DATABASE_URL).");
7113
7052
  const dbType = config.database.type || "sqlite";
7114
7053
  const { getDatabase } = await import("@happyvertical/sql");
7115
- const { materializeTenantHierarchy, TenantHierarchyMaterializationError } = await import("./dist-D5GdZ8W6.js");
7054
+ const { materializeTenantHierarchy, TenantHierarchyMaterializationError } = await import("./dist-m9bKxs6w.js");
7116
7055
  db = await getDatabase({
7117
7056
  type: dbType,
7118
7057
  url: config.database.url
@@ -7142,7 +7081,7 @@ var dbMaterializeTenantHierarchyCommand = {
7142
7081
  }
7143
7082
  console.log(result.changes.length > 0 ? `\n✓ Materialized the hierarchy for ${result.changes.length} of ${result.total} tenant(s).\n` : `\nAll ${result.total} tenant(s) already carry the correct hierarchy; nothing to do.\n`);
7144
7083
  } catch (error) {
7145
- console.error(`\n❌ Tenant hierarchy materialization failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
7084
+ console.error(`\n❌ Tenant hierarchy materialization failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
7146
7085
  process.exitCode = 1;
7147
7086
  } finally {
7148
7087
  await closeDatabaseConnection(db);
@@ -7192,7 +7131,7 @@ var dbMigrateAgentScheduleSlugsCommand = {
7192
7131
  });
7193
7132
  console.log(result.ran ? `✓ Backfilled ${result.updated} AgentSchedule slug(s); no schedules were run.\n` : "No schedule slug migration was needed.\n");
7194
7133
  } catch (error) {
7195
- console.error(`\n❌ AgentSchedule slug migration failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
7134
+ console.error(`\n❌ AgentSchedule slug migration failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
7196
7135
  process.exitCode = 1;
7197
7136
  } finally {
7198
7137
  await closeDatabaseConnection(db);
@@ -7286,7 +7225,7 @@ var dbMigrateInt8Command = {
7286
7225
  });
7287
7226
  console.log(result.ran ? `\n✓ Widened ${result.widenedColumns.length} column(s) to BIGINT.\n` : "\nNo widening was applied; no legacy int4 columns remain.\n");
7288
7227
  } catch (error) {
7289
- console.error(`\n❌ int8 migration failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
7228
+ console.error(`\n❌ int8 migration failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
7290
7229
  process.exitCode = 1;
7291
7230
  } finally {
7292
7231
  await closeDatabaseConnection(db);
@@ -7321,7 +7260,7 @@ var dbMigrateLedgerAccountsCommand = {
7321
7260
  if (dbType !== "postgres") throw new Error("db:migrate-ledger-accounts currently supports PostgreSQL only; no changes were made. See the smrt-ledgers README for SQLite.");
7322
7261
  await autoDiscoverAndLoad();
7323
7262
  const { getDatabase } = await import("@happyvertical/sql");
7324
- const { migrateLedgerAccountsTable, planLedgerAccountsTableMove } = await import("./dist-DIGbZpp6.js");
7263
+ const { migrateLedgerAccountsTable, planLedgerAccountsTableMove } = await import("./dist-F98s-wG1.js");
7325
7264
  db = await getDatabase({
7326
7265
  type: dbType,
7327
7266
  url: config.database.url
@@ -7345,7 +7284,7 @@ var dbMigrateLedgerAccountsCommand = {
7345
7284
  console.log(`✓ Moved ${result.moved} ledger account(s) to ledger_accounts; ${result.remainingLegacyRows} row(s) remain in accounts.`);
7346
7285
  if (result.detachedForeignKeys.length > 0) console.log(`✓ Detached ${result.detachedForeignKeys.join(", ")} from accounts. Run db:migrate to add them against ledger_accounts.\n`);
7347
7286
  } catch (error) {
7348
- console.error(`\n❌ Ledger accounts table move failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
7287
+ console.error(`\n❌ Ledger accounts table move failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
7349
7288
  process.exitCode = 1;
7350
7289
  } finally {
7351
7290
  await closeDatabaseConnection(db);
@@ -7398,7 +7337,7 @@ var dbMigrateNullEqualIndexesCommand = {
7398
7337
  console.log(`Applied ${result.statements.length} index statements atomically.`);
7399
7338
  console.log("Refresh/restart database connections in EVERY application process to clear cached index capability probes. Until then the existing upsert fallback remains correct.");
7400
7339
  } catch (error) {
7401
- console.error(`NULL-equal conflict-index migration failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}`);
7340
+ console.error(`NULL-equal conflict-index migration failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}`);
7402
7341
  process.exitCode = 1;
7403
7342
  } finally {
7404
7343
  await closeDatabaseConnection(db);
@@ -7730,7 +7669,7 @@ var dbMigrateUuidCommand = {
7730
7669
  await convertPostgresUuidColumns(tx, declaredUuid, false);
7731
7670
  });
7732
7671
  } catch (error) {
7733
- console.error(`\n❌ uuid migration failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
7672
+ console.error(`\n❌ uuid migration failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
7734
7673
  process.exitCode = 1;
7735
7674
  } finally {
7736
7675
  await closeDatabaseConnection(db);
@@ -8431,7 +8370,7 @@ async function runLegacyQualifiedNameReport(options = {}) {
8431
8370
  } catch (error) {
8432
8371
  return {
8433
8372
  report: null,
8434
- error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error))
8373
+ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))
8435
8374
  };
8436
8375
  } finally {
8437
8376
  await closeDatabaseConnection(db);
@@ -8514,7 +8453,7 @@ var dbMigrateQualifiedNamesCommand = {
8514
8453
  if (result.skippedDuplicates.length > 0) process.exitCode = 1;
8515
8454
  console.log(result.recorded ? `\n✓ Recorded ${result.backfillName}.\n` : "\nNot recorded: references remain.\n");
8516
8455
  } catch (error) {
8517
- console.error(`\n❌ Qualified-name backfill failed: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}\n`);
8456
+ console.error(`\n❌ Qualified-name backfill failed: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}\n`);
8518
8457
  process.exitCode = 1;
8519
8458
  } finally {
8520
8459
  await closeDatabaseConnection(db);
@@ -9485,7 +9424,7 @@ async function settleDeferredCompatibilityAfterMigrate(db, dbType, { verbose })
9485
9424
  const { settled } = await ensureDeferredSystemTableCompatibility(db, dbType);
9486
9425
  if (verbose) console.log(settled ? "Deferred system-table compatibility settled (_smrt_jobs, _smrt_job_events)\n" : "Deferred system-table compatibility pending (jobs tables not present)\n");
9487
9426
  } catch (error) {
9488
- console.warn(`⚠️ Deferred system-table compatibility did not complete: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}`);
9427
+ console.warn(`⚠️ Deferred system-table compatibility did not complete: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}`);
9489
9428
  console.warn(" It will be retried the next time the framework starts.\n");
9490
9429
  }
9491
9430
  }
@@ -10042,7 +9981,7 @@ export default testManifest;
10042
9981
  await db.query(`DROP TABLE IF EXISTS ${quoteIdentifier(tableName)}${cascade}`);
10043
9982
  console.log(` ✓ Dropped ${tableName}`);
10044
9983
  } catch (error) {
10045
- if (options.verbose) console.log(` ⚠️ Could not drop ${tableName}: ${redactConnectionStringsInText(String(error))}`);
9984
+ if (options.verbose) console.log(` ⚠️ Could not drop ${tableName}: ${redactDatabaseUrlsInText(String(error))}`);
10046
9985
  throw new Error(`Refusing to continue after failing to drop ${tableName}; dependency or foreign-key constraints may still be active.`, { cause: error });
10047
9986
  }
10048
9987
  }
@@ -10060,8 +9999,8 @@ export default testManifest;
10060
9999
  try {
10061
10000
  await schemaManager.ensureTables(schemas);
10062
10001
  } catch (error) {
10063
- console.error(` ✗ Schema creation failed: ${redactConnectionStringsInText(String(error))}`);
10064
- if (options.verbose && error instanceof Error && error.stack) console.error(`\n${redactConnectionStringsInText(error.stack)}\n`);
10002
+ console.error(` ✗ Schema creation failed: ${redactDatabaseUrlsInText(String(error))}`);
10003
+ if (options.verbose && error instanceof Error && error.stack) console.error(`\n${redactDatabaseUrlsInText(error.stack)}\n`);
10065
10004
  throw new Error("Refusing to report database setup success after schema creation failed.", { cause: error });
10066
10005
  }
10067
10006
  let tablesCreated = 0;
@@ -10094,12 +10033,12 @@ export default testManifest;
10094
10033
  } catch (error) {
10095
10034
  console.error(formatSchemaCommandFailureHeader(error, "\n❌ Database setup failed:"));
10096
10035
  if (error instanceof Error) {
10097
- console.error(` ${redactConnectionStringsInText(error.message)}`);
10036
+ console.error(` ${redactDatabaseUrlsInText(error.message)}`);
10098
10037
  if (options.verbose && error.stack) {
10099
10038
  console.error("\nStack trace:");
10100
- console.error(redactConnectionStringsInText(error.stack));
10039
+ console.error(redactDatabaseUrlsInText(error.stack));
10101
10040
  }
10102
- } else console.error(redactConnectionStringsInText(String(error)));
10041
+ } else console.error(redactDatabaseUrlsInText(String(error)));
10103
10042
  process.exitCode = 1;
10104
10043
  return;
10105
10044
  } finally {
@@ -10131,7 +10070,7 @@ export default testManifest;
10131
10070
  }
10132
10071
  } catch (error) {
10133
10072
  console.error("❌ Failed to clear cache:");
10134
- if (error instanceof Error) console.error(` ${redactConnectionStringsInText(error.message)}`);
10073
+ if (error instanceof Error) console.error(` ${redactDatabaseUrlsInText(error.message)}`);
10135
10074
  process.exit(1);
10136
10075
  }
10137
10076
  }
@@ -10269,18 +10208,18 @@ export default testManifest;
10269
10208
  } catch (error) {
10270
10209
  if (options.json) console.log(JSON.stringify({
10271
10210
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
10272
- error: redactConnectionStringsInText(error instanceof Error ? error.message : String(error)),
10211
+ error: redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error)),
10273
10212
  duration: Date.now() - startTime
10274
10213
  }, null, 2));
10275
10214
  else {
10276
10215
  console.error("\n❌ Validation failed:");
10277
10216
  if (error instanceof Error) {
10278
- console.error(` ${redactConnectionStringsInText(error.message)}`);
10217
+ console.error(` ${redactDatabaseUrlsInText(error.message)}`);
10279
10218
  if (options.verbose && error.stack) {
10280
10219
  console.error("\nStack trace:");
10281
- console.error(redactConnectionStringsInText(error.stack));
10220
+ console.error(redactDatabaseUrlsInText(error.stack));
10282
10221
  }
10283
- } else console.error(redactConnectionStringsInText(String(error)));
10222
+ } else console.error(redactDatabaseUrlsInText(String(error)));
10284
10223
  }
10285
10224
  process.exit(1);
10286
10225
  }
@@ -10535,7 +10474,7 @@ export default testManifest;
10535
10474
  try {
10536
10475
  beforeCount = await countOrphanRows(db, countSql);
10537
10476
  } catch (error) {
10538
- console.log(` ✗ ${item.tableName}.${item.column}: orphan-count probe failed, withholding this disposition: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))}`);
10477
+ console.log(` ✗ ${item.tableName}.${item.column}: orphan-count probe failed, withholding this disposition: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))}`);
10539
10478
  continue;
10540
10479
  }
10541
10480
  if (!item.action.foreignKey) continue;
@@ -10829,10 +10768,10 @@ export default testManifest;
10829
10768
  skippedCount += results.filter((result) => result.success && (result.skipped || result.applied === false || result.execution_time_ms === 0)).length;
10830
10769
  } catch (error) {
10831
10770
  errorCount++;
10832
- const errorMsg = redactConnectionStringsInText(error instanceof Error ? error.message : String(error));
10771
+ const errorMsg = redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error));
10833
10772
  console.error(` ✗ atomic schema migration failed: ${errorMsg}`);
10834
- if (error instanceof Error && getErrorContext(error)?.originalError) console.error(` Cause: ${redactConnectionStringsInText(String(getErrorContext(error)?.originalError))}`);
10835
- if (options.verbose && error instanceof Error && error.stack) console.error(`\n${redactConnectionStringsInText(error.stack)}\n`);
10773
+ if (error instanceof Error && getErrorContext(error)?.originalError) console.error(` Cause: ${redactDatabaseUrlsInText(String(getErrorContext(error)?.originalError))}`);
10774
+ if (options.verbose && error instanceof Error && error.stack) console.error(`\n${redactDatabaseUrlsInText(error.stack)}\n`);
10836
10775
  console.error(deferredIndexMigrations > 0 ? " Non-index changes in this batch were committed; concurrent index builds that did not finish are recorded failed and will be retried on the next db:migrate." : " Rolled back all schema changes from this migration batch, including any successful steps shown above.");
10837
10776
  }
10838
10777
  }
@@ -10847,7 +10786,7 @@ export default testManifest;
10847
10786
  const afterCount = await countOrphanRows(db, pending.countSql);
10848
10787
  console.log(` ✓ ${pending.tableName}.${pending.column}: nulled ${Math.max(pending.beforeCount - afterCount, 0)} orphan reference(s) (${afterCount} remaining)`);
10849
10788
  } catch (error) {
10850
- console.log(` ✓ ${pending.tableName}.${pending.column}: orphan references nulled and foreign key added (post-apply count unavailable: ${redactConnectionStringsInText(error instanceof Error ? error.message : String(error))})`);
10789
+ console.log(` ✓ ${pending.tableName}.${pending.column}: orphan references nulled and foreign key added (post-apply count unavailable: ${redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error))})`);
10851
10790
  }
10852
10791
  console.log();
10853
10792
  }
@@ -10908,8 +10847,8 @@ export default testManifest;
10908
10847
  } else if (repair.conflicts.length === 0) stiSkippedCount++;
10909
10848
  } catch (error) {
10910
10849
  const qualifiedName = resolution.currentQualifiedName;
10911
- const errorMsg = redactConnectionStringsInText(error instanceof Error ? error.message : String(error));
10912
- const originalError = getErrorContext(error)?.originalError ? redactConnectionStringsInText(String(getErrorContext(error)?.originalError)) : void 0;
10850
+ const errorMsg = redactDatabaseUrlsInText(error instanceof Error ? error.message : String(error));
10851
+ const originalError = getErrorContext(error)?.originalError ? redactDatabaseUrlsInText(String(getErrorContext(error)?.originalError)) : void 0;
10913
10852
  console.error(` ✗ ${tableName}: "${metaType}" → "${qualifiedName}" failed: ${originalError || errorMsg}`);
10914
10853
  stiErrorCount++;
10915
10854
  }
@@ -10963,17 +10902,17 @@ export default testManifest;
10963
10902
  } catch (error) {
10964
10903
  console.error(formatSchemaCommandFailureHeader(error, "\n❌ Migration failed:"));
10965
10904
  if (error instanceof Error) {
10966
- console.error(` ${redactConnectionStringsInText(error.message)}`);
10905
+ console.error(` ${redactDatabaseUrlsInText(error.message)}`);
10967
10906
  const ctx = getErrorContext(error);
10968
10907
  if (ctx) {
10969
- if (ctx.originalError) console.error(` Database error: ${redactConnectionStringsInText(String(ctx.originalError))}`);
10970
- if (ctx.sql) console.error(` Failed SQL: ${redactConnectionStringsInText(String(ctx.sql))}`);
10908
+ if (ctx.originalError) console.error(` Database error: ${redactDatabaseUrlsInText(String(ctx.originalError))}`);
10909
+ if (ctx.sql) console.error(` Failed SQL: ${redactDatabaseUrlsInText(String(ctx.sql))}`);
10971
10910
  }
10972
10911
  if (options.verbose && error.stack) {
10973
10912
  console.error("\nStack trace:");
10974
- console.error(redactConnectionStringsInText(error.stack));
10913
+ console.error(redactDatabaseUrlsInText(error.stack));
10975
10914
  }
10976
- } else console.error(redactConnectionStringsInText(String(error)));
10915
+ } else console.error(redactDatabaseUrlsInText(String(error)));
10977
10916
  process.exitCode = 1;
10978
10917
  return;
10979
10918
  } finally {
@@ -0,0 +1,40 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { redactDatabaseUrl, redactDatabaseUrlsInText } from "@happyvertical/smrt-core/utils/database-url";
3
+ //#region src/commands/db-command-utils.ts
4
+ var db_command_utils_exports = /* @__PURE__ */ __exportAll({
5
+ closeDatabaseConnection: () => closeDatabaseConnection,
6
+ formatDatabaseDisplayUrl: () => formatDatabaseDisplayUrl,
7
+ quoteIdentifier: () => quoteIdentifier,
8
+ redactDatabaseUrl: () => redactDatabaseUrl,
9
+ redactDatabaseUrlsInText: () => redactDatabaseUrlsInText
10
+ });
11
+ /**
12
+ * Quote a SQL identifier (table name, column name, etc.).
13
+ *
14
+ * Uses double quotes, the ANSI SQL standard understood by SQLite, PostgreSQL,
15
+ * and DuckDB, and escapes embedded double quotes by doubling them.
16
+ */
17
+ function quoteIdentifier(name) {
18
+ return `"${name.replace(/"/g, "\"\"")}"`;
19
+ }
20
+ /**
21
+ * Render the configured database for command output: scheme, username, host,
22
+ * port and database at most — never the password or query string (#3527).
23
+ * A bare local path (`./data/dev.db`, `:memory:`) is shown as
24
+ * `<dbType>://<path>`.
25
+ */
26
+ function formatDatabaseDisplayUrl(dbType, dbUrl) {
27
+ const redacted = redactDatabaseUrl(dbUrl);
28
+ return /^[a-z][a-z0-9+.-]*:/i.test(redacted) || redacted !== dbUrl ? redacted : `${dbType}://${redacted}`;
29
+ }
30
+ async function closeDatabaseConnection(db) {
31
+ if (!db || typeof db !== "object") return;
32
+ const closeable = db;
33
+ const close = closeable.close ?? closeable.client?.end ?? closeable.client?.close;
34
+ if (typeof close !== "function") return;
35
+ try {
36
+ await close.call(closeable.close ? closeable : closeable.client);
37
+ } catch {}
38
+ }
39
+ //#endregion
40
+ export { redactDatabaseUrlsInText as a, quoteIdentifier as i, db_command_utils_exports as n, formatDatabaseDisplayUrl as r, closeDatabaseConnection as t };
@@ -0,0 +1,20 @@
1
+ import "./NostrIdentity-AC8fAdxe-DKxKyu_a.js";
2
+ import "./ApiKey-CVmlf3V6-BAeHuH48.js";
3
+ import "./ApiKeyCollection-CiiDNFdD-CMGF3_ul.js";
4
+ import "./AuditLogCollection-WDHL-_AF-G2UOSM3H.js";
5
+ import "./NostrIdentityCollection-CctlECpX-fkAPnK02.js";
6
+ import "./OidcIdentity-BjRu3n1g-CzvSN6Wz.js";
7
+ import "./OidcIdentityCollection-B4jYh36_-6UWtXCwi.js";
8
+ import "./ProfileAssetCollection-HeMtjBc0-Cz4MOeSB.js";
9
+ import { a as ProfileCollection } from "./ProfileCollection-Bt6IJK49-CFyOiVFz.js";
10
+ import "./ProfileLinkCollection-u1hhzKTm-CAfIjZ4f.js";
11
+ import "./ProfileMetadataCollection-BIYKy4Y3-CqcaAHAJ.js";
12
+ import "./ProfileMetafieldCollection-Buz7gzag-BNRo6e4x.js";
13
+ import "./ProfileRelationshipCollection-C4g_QLI4-DeJzJ_hF.js";
14
+ import "./ProfileRelationshipTermCollection-C9J7mC7P-ChIFqjCg.js";
15
+ import "./ProfileRelationshipType-U7IwF6Wf-DNavf24e.js";
16
+ import "./ProfileRelationshipTypeCollection-_n22WqTb-DiZUWvev.js";
17
+ import "./oidcProvisioningPrimitives-CYood-2M-DKUWB1oI.js";
18
+ import "./resolveIdentity-CvGDegU6-BePPF1Iv.js";
19
+ import "./dist-m9bKxs6w.js";
20
+ export { ProfileCollection };