@akal/supaforge 0.0.46 → 0.0.47

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseCommand
3
- } from "./chunk-CKH6J7DI.js";
3
+ } from "./chunk-TU5UIODX.js";
4
4
  import "./chunk-RC7ZU7OV.js";
5
5
  import "./chunk-KHXEES2M.js";
6
6
  import "./chunk-SQ52YBKK.js";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  captureSnapshot
3
- } from "./chunk-67JVGG3G.js";
3
+ } from "./chunk-3SEVACCT.js";
4
4
  import {
5
5
  checkPgDumpCompat,
6
+ pgToolConnection,
6
7
  splitSqlStatements
7
- } from "./chunk-YE3RQLCR.js";
8
+ } from "./chunk-YYS4FJ23.js";
8
9
  import {
9
10
  newPgClient,
10
11
  pgQuery,
@@ -95,8 +96,15 @@ import { tmpdir } from "os";
95
96
  import { join } from "path";
96
97
  import { promisify } from "util";
97
98
  var run = promisify(execFile);
98
- function privilegeEntries(listing) {
99
- return listing.split("\n").filter((line) => /^\d+;\s+\d+\s+\d+\s+(?:DEFAULT\s+)?ACL\s/.test(line));
99
+ function privilegeEntries(listing, excludeSchemas = []) {
100
+ const excluded = new Set(excludeSchemas);
101
+ return listing.split("\n").filter((line) => {
102
+ const m = /^\d+;\s+\d+\s+\d+\s+(?:DEFAULT\s+)?ACL\s+(\S+)\s+(.*)$/.exec(line);
103
+ if (!m) return false;
104
+ const [, schema, rest] = m;
105
+ const subject = schema === "-" ? /^SCHEMA\s+(\S+)/.exec(rest)?.[1] : schema;
106
+ return subject === void 0 || !excluded.has(subject);
107
+ });
100
108
  }
101
109
  function privilegeStatements(sql) {
102
110
  const body = sql.split("\n").filter((line) => !line.startsWith("\\")).join("\n");
@@ -135,6 +143,7 @@ async function restorePrivileges(opts) {
135
143
  try {
136
144
  const archive = join(dir, "schema.dump");
137
145
  const list = join(dir, "acl.list");
146
+ const remote = pgToolConnection(opts.remoteUrl);
138
147
  await run(opts.pgDumpPath, [
139
148
  "--format=custom",
140
149
  "--schema-only",
@@ -142,10 +151,10 @@ async function restorePrivileges(opts) {
142
151
  ...(opts.excludeSchemas ?? []).map((s) => `--exclude-schema=${s}`),
143
152
  "--file",
144
153
  archive,
145
- opts.remoteUrl
146
- ], { maxBuffer: 64 * 1024 * 1024 });
154
+ remote.url
155
+ ], { maxBuffer: 64 * 1024 * 1024, env: remote.env });
147
156
  const { stdout: listing } = await run(opts.pgRestorePath, ["--list", archive], { maxBuffer: 256 * 1024 * 1024 });
148
- const entries = privilegeEntries(listing);
157
+ const entries = privilegeEntries(listing, opts.excludeSchemas);
149
158
  if (entries.length === 0) return { granted: 0, notGranted: [], failures: [] };
150
159
  await writeFile(list, entries.join("\n") + "\n");
151
160
  const { stdout: sql } = await run(opts.pgRestorePath, ["--use-list", list, "--file", "-", archive], { maxBuffer: 256 * 1024 * 1024 });
@@ -278,18 +287,19 @@ async function tryDumpRestore(sourceUrl, newDb, schemaOnly, pgDumpPath = "pg_dum
278
287
  } finally {
279
288
  await client.end();
280
289
  }
281
- const dumpArgs = ["--format=custom", "--no-owner", sourceUrl];
290
+ const source = pgToolConnection(sourceUrl);
291
+ const dumpArgs = ["--format=custom", "--no-owner", source.url];
282
292
  if (schemaOnly) dumpArgs.unshift("--schema-only");
283
- const targetUrl = replaceDbName(sourceUrl, newDb);
293
+ const target = pgToolConnection(replaceDbName(sourceUrl, newDb));
284
294
  const restoreArgs = [
285
295
  "--format=custom",
286
296
  "--no-owner",
287
- `--dbname=${targetUrl}`
297
+ `--dbname=${target.url}`
288
298
  ];
289
299
  try {
290
300
  await new Promise((resolve2, reject) => {
291
- const dump = spawn(pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"] });
292
- const restore = spawn(pgRestorePath, restoreArgs, { stdio: [dump.stdout, "pipe", "pipe"] });
301
+ const dump = spawn(pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"], env: source.env });
302
+ const restore = spawn(pgRestorePath, restoreArgs, { stdio: [dump.stdout, "pipe", "pipe"], env: target.env });
293
303
  let restoreStderr = "";
294
304
  restore.stderr?.on("data", (chunk) => {
295
305
  restoreStderr += chunk.toString();
@@ -473,18 +483,20 @@ async function cloneRemoteToLocal(opts) {
473
483
  dumpArgs.push(`--exclude-schema=${schema}`);
474
484
  }
475
485
  }
476
- dumpArgs.push(opts.remoteUrl);
486
+ const remote = pgToolConnection(opts.remoteUrl);
487
+ const local = pgToolConnection(localDbUrl);
488
+ dumpArgs.push(remote.url);
477
489
  const restoreArgs = [
478
490
  "--format=custom",
479
491
  "--no-owner",
480
492
  "--no-acl",
481
- `--dbname=${localDbUrl}`
493
+ `--dbname=${local.url}`
482
494
  ];
483
495
  let restoreLog = "";
484
496
  try {
485
497
  restoreLog = await new Promise((resolve2, reject) => {
486
- const dump = spawn(compat.pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"] });
487
- const restore = spawn(compat.pgRestorePath, restoreArgs, { stdio: ["pipe", "pipe", "pipe"] });
498
+ const dump = spawn(compat.pgDumpPath, dumpArgs, { stdio: ["ignore", "pipe", "pipe"], env: remote.env });
499
+ const restore = spawn(compat.pgRestorePath, restoreArgs, { stdio: ["pipe", "pipe", "pipe"], env: local.env });
488
500
  let bytesTransferred = 0;
489
501
  dump.stdout.on("data", (chunk) => {
490
502
  bytesTransferred += chunk.length;
@@ -732,4 +744,4 @@ export {
732
744
  isCloneDatabase,
733
745
  sourceLooksLikeCloneOf
734
746
  };
735
- //# sourceMappingURL=chunk-YDISW5X7.js.map
747
+ //# sourceMappingURL=chunk-2XMRTAFX.js.map
@@ -3,8 +3,9 @@ import {
3
3
  describeMissingPgDump,
4
4
  getServerMajorVersion,
5
5
  normalizeRoles,
6
+ pgToolConnection,
6
7
  resolvePgDumpPath
7
- } from "./chunk-YE3RQLCR.js";
8
+ } from "./chunk-YYS4FJ23.js";
8
9
  import {
9
10
  Check,
10
11
  inRolledBackTransaction,
@@ -31,7 +32,7 @@ import {
31
32
  } from "./chunk-SQ52YBKK.js";
32
33
 
33
34
  // src/snapshot.ts
34
- import { mkdir, writeFile, readFile, readdir, rm } from "fs/promises";
35
+ import { mkdir, writeFile, readFile, readdir, rm, chmod } from "fs/promises";
35
36
  import { join, resolve } from "path";
36
37
  import { execFile as execFileCb } from "child_process";
37
38
  import { promisify } from "util";
@@ -604,7 +605,8 @@ async function captureSnapshot(options) {
604
605
  const cwd = options.cwd ?? process.cwd();
605
606
  const timestamp = generateTimestamp();
606
607
  const dir = options.outputDir ? join(resolve(options.outputDir), timestamp) : snapshotDir(cwd, timestamp);
607
- await mkdir(dir, { recursive: true });
608
+ await mkdir(dir, { recursive: true, mode: 448 });
609
+ await chmod(dir, 448);
608
610
  const queryFn = options.queryFn ?? pgQuery;
609
611
  const fetchFn = options.fetchFn ?? globalThis.fetch.bind(globalThis);
610
612
  const ignoreSchemas = options.config.ignoreSchemas ?? DEFAULT_IGNORE_SCHEMAS;
@@ -704,14 +706,15 @@ async function captureSchemaSql(dir, dbUrl, schemas) {
704
706
  sqlSkipReason: `${await describeMissingPgDump(serverMajor)} \u2014 schema.json was still captured, but restore cannot replay the schema`
705
707
  };
706
708
  }
709
+ const conn = pgToolConnection(dbUrl);
707
710
  const { stdout } = await execFile(resolved.path, [
708
- dbUrl,
711
+ conn.url,
709
712
  "--schema-only",
710
713
  "--no-owner",
711
714
  "--no-privileges",
712
715
  // Quoted: pg_dump reads --schema as a pattern, folding `App Data` to lower case.
713
716
  ...schemas.map((s) => `--schema=${quoteName(s)}`)
714
- ], { maxBuffer: 256 * 1024 * 1024, timeout: 3e5 });
717
+ ], { maxBuffer: 256 * 1024 * 1024, timeout: 3e5, env: conn.env });
715
718
  if (stdout.trim().length === 0) {
716
719
  return { sqlSkipReason: "pg_dump produced an empty schema dump" };
717
720
  }
@@ -1249,4 +1252,4 @@ export {
1249
1252
  DEFAULT_KEEP_COUNT,
1250
1253
  pruneSnapshots
1251
1254
  };
1252
- //# sourceMappingURL=chunk-67JVGG3G.js.map
1255
+ //# sourceMappingURL=chunk-3SEVACCT.js.map
@@ -2,12 +2,12 @@ import {
2
2
  captureSnapshot,
3
3
  findLatestSnapshot,
4
4
  loadSnapshot
5
- } from "./chunk-67JVGG3G.js";
5
+ } from "./chunk-3SEVACCT.js";
6
6
  import {
7
7
  isCommentOnly,
8
8
  slugify,
9
9
  splitSqlStatements
10
- } from "./chunk-YE3RQLCR.js";
10
+ } from "./chunk-YYS4FJ23.js";
11
11
  import {
12
12
  MIGRATIONS_SUBDIR,
13
13
  SUPAFORGE_DIR
@@ -243,4 +243,4 @@ export {
243
243
  loadMigrations,
244
244
  listMigrationFiles
245
245
  };
246
- //# sourceMappingURL=chunk-C32M67YH.js.map
246
+ //# sourceMappingURL=chunk-4TBYWXUK.js.map
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  targetFingerprint,
3
3
  writtenAgainstLine
4
- } from "./chunk-LV44B3BX.js";
4
+ } from "./chunk-YQLVRHJA.js";
5
5
  import {
6
6
  RolesCheck,
7
7
  isDestructiveSql,
8
8
  runDbDiff
9
- } from "./chunk-XBXMOGI3.js";
9
+ } from "./chunk-WNZCOYOK.js";
10
10
  import {
11
11
  slugify,
12
12
  splitSqlStatements
13
- } from "./chunk-YE3RQLCR.js";
13
+ } from "./chunk-YYS4FJ23.js";
14
14
  import {
15
15
  DEFAULT_MIGRATIONS_DIR,
16
16
  pgQuery
@@ -89,4 +89,4 @@ export {
89
89
  writeMigrationFile,
90
90
  generateTimestamp
91
91
  };
92
- //# sourceMappingURL=chunk-ZBQLDCYV.js.map
92
+ //# sourceMappingURL=chunk-CRUFF6K5.js.map
@@ -6,13 +6,13 @@ import {
6
6
  formatSkips,
7
7
  renderDetailed,
8
8
  renderSummary
9
- } from "./chunk-FFRGDQMV.js";
9
+ } from "./chunk-EB6PCOIL.js";
10
10
  import {
11
11
  createDefaultRegistry,
12
12
  proveBeforeApply,
13
13
  scan,
14
14
  summarizeByKind
15
- } from "./chunk-AUNVMGTR.js";
15
+ } from "./chunk-EGXQ37PA.js";
16
16
  import {
17
17
  CHECK_META,
18
18
  CHECK_NAMES,
@@ -24,17 +24,17 @@ import {
24
24
  psqlBeside,
25
25
  resolveTableFilter,
26
26
  withDatabase
27
- } from "./chunk-XBXMOGI3.js";
27
+ } from "./chunk-WNZCOYOK.js";
28
28
  import {
29
29
  renderTip
30
30
  } from "./chunk-RQCXGO37.js";
31
31
  import {
32
32
  BaseCommand
33
- } from "./chunk-CKH6J7DI.js";
33
+ } from "./chunk-TU5UIODX.js";
34
34
  import {
35
35
  isCloneDatabase,
36
36
  sourceLooksLikeCloneOf
37
- } from "./chunk-YDISW5X7.js";
37
+ } from "./chunk-2XMRTAFX.js";
38
38
  import {
39
39
  describeMissingPgDump,
40
40
  getServerMajorVersion,
@@ -42,7 +42,7 @@ import {
42
42
  parseFlagList,
43
43
  resolvePgDumpPath,
44
44
  splitSqlStatements
45
- } from "./chunk-YE3RQLCR.js";
45
+ } from "./chunk-YYS4FJ23.js";
46
46
  import {
47
47
  Preflight,
48
48
  pgQuery,
@@ -754,4 +754,4 @@ export {
754
754
  inertApplyFlags,
755
755
  Diff
756
756
  };
757
- //# sourceMappingURL=chunk-AJ53RPJS.js.map
757
+ //# sourceMappingURL=chunk-CUGDLO2L.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CHECK_META,
3
3
  isComparisonCheck
4
- } from "./chunk-XBXMOGI3.js";
4
+ } from "./chunk-WNZCOYOK.js";
5
5
  import {
6
6
  CHECK_LINE_PADDING,
7
7
  bold,
@@ -241,4 +241,4 @@ export {
241
241
  renderDetailed,
242
242
  formatSkips
243
243
  };
244
- //# sourceMappingURL=chunk-FFRGDQMV.js.map
244
+ //# sourceMappingURL=chunk-EB6PCOIL.js.map
@@ -21,7 +21,7 @@ import {
21
21
  sqlToIssues,
22
22
  withPlatformExtensionCalls,
23
23
  withoutAbsentRoles
24
- } from "./chunk-XBXMOGI3.js";
24
+ } from "./chunk-WNZCOYOK.js";
25
25
  import {
26
26
  RealtimeCheck,
27
27
  createPolicySql,
@@ -33,10 +33,10 @@ import {
33
33
  readJsonArray,
34
34
  readJsonObject,
35
35
  schemaPolicySql
36
- } from "./chunk-67JVGG3G.js";
36
+ } from "./chunk-3SEVACCT.js";
37
37
  import {
38
38
  splitSqlStatements
39
- } from "./chunk-YE3RQLCR.js";
39
+ } from "./chunk-YYS4FJ23.js";
40
40
  import {
41
41
  Check,
42
42
  CheckSkipped,
@@ -418,7 +418,8 @@ var SchemaCheck = class extends Check {
418
418
  let issues = sqlToIssues(result, "schema", ignoreSchemas, ignoredSchemaTables);
419
419
  const moves = platformExtensionMoves(issues);
420
420
  if (moves.length) {
421
- issues = withPlatformExtensionCalls(issues, moves, await this.extensionFunctions(ctx.target.dbUrl, moves));
421
+ const { owned, shadows } = await this.extensionFunctions(ctx.target.dbUrl, moves);
422
+ issues = withPlatformExtensionCalls(issues, moves, owned, shadows);
422
423
  }
423
424
  const roles = await this.targetRoles(ctx.target.dbUrl);
424
425
  return roles?.size ? withoutAbsentRoles(issues, roles) : issues;
@@ -440,25 +441,39 @@ var SchemaCheck = class extends Check {
440
441
  * DB error here never blocks the main schema diff.
441
442
  */
442
443
  /**
443
- * The functions each extension owns on the target, by name. Unreadable,
444
- * none: the calls are then left as the source wrote them.
444
+ * The functions each extension owns on the target, with how many arguments
445
+ * each takes, and the user's own functions of the same names in the schemas
446
+ * the source keeps those extensions in, which a call could mean instead.
447
+ * Unreadable, none: the calls are then left as the source wrote them.
445
448
  */
446
449
  async extensionFunctions(dbUrl, moves) {
447
450
  const owned = /* @__PURE__ */ new Map();
451
+ const shadows = [];
448
452
  try {
449
- const rows = await this.queryFn(dbUrl, `SELECT e.extname, p.proname
453
+ const rows = await this.queryFn(dbUrl, `SELECT e.extname, p.proname, p.pronargs, p.pronargdefaults, p.provariadic <> 0 AS variadic
450
454
  FROM pg_depend d
451
455
  JOIN pg_extension e ON e.oid = d.refobjid
452
456
  JOIN pg_proc p ON p.oid = d.objid
453
457
  WHERE d.classid = 'pg_proc'::regclass AND d.refclassid = 'pg_extension'::regclass
454
458
  AND d.deptype = 'e' AND e.extname = ANY($1)`, [moves.map((m) => m.name)]);
455
- for (const { extname, proname } of rows) {
456
- if (!owned.has(extname)) owned.set(extname, /* @__PURE__ */ new Set());
457
- owned.get(extname).add(proname);
459
+ for (const row of rows) {
460
+ const extname = String(row.extname);
461
+ if (!owned.has(extname)) owned.set(extname, []);
462
+ owned.get(extname).push(arity(row));
458
463
  }
464
+ const names = [...new Set(rows.map((r) => String(r.proname)))];
465
+ const others = await this.queryFn(
466
+ dbUrl,
467
+ `SELECT n.nspname, p.proname, p.pronargs, p.pronargdefaults, p.provariadic <> 0 AS variadic
468
+ FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
469
+ WHERE n.nspname = ANY($1) AND p.proname = ANY($2)
470
+ AND NOT EXISTS (SELECT FROM pg_depend d WHERE d.classid = 'pg_proc'::regclass AND d.objid = p.oid AND d.deptype = 'e')`,
471
+ [[...new Set(moves.map((m) => m.sourceSchema))], names]
472
+ );
473
+ for (const row of others) shadows.push({ schema: String(row.nspname), ...arity(row) });
459
474
  } catch {
460
475
  }
461
- return owned;
476
+ return { owned, shadows };
462
477
  }
463
478
  /** The target's roles, or undefined when they cannot be read. */
464
479
  async targetRoles(dbUrl) {
@@ -487,6 +502,14 @@ var SchemaCheck = class extends Check {
487
502
  }
488
503
  }
489
504
  };
505
+ function arity(row) {
506
+ const nargs = Number(row.pronargs ?? 0);
507
+ return {
508
+ name: String(row.proname),
509
+ minArgs: nargs - Number(row.pronargdefaults ?? 0),
510
+ maxArgs: row.variadic === true ? Infinity : nargs
511
+ };
512
+ }
490
513
 
491
514
  // src/checks/rls.ts
492
515
  var RlsCheck = class extends Check {
@@ -2444,4 +2467,4 @@ export {
2444
2467
  createDefaultRegistry,
2445
2468
  proveBeforeApply
2446
2469
  };
2447
- //# sourceMappingURL=chunk-AUNVMGTR.js.map
2470
+ //# sourceMappingURL=chunk-EGXQ37PA.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadMigrations
3
- } from "./chunk-C32M67YH.js";
3
+ } from "./chunk-4TBYWXUK.js";
4
4
  import {
5
5
  ensureMigrationsTable,
6
6
  getAppliedVersions
@@ -18,16 +18,16 @@ import {
18
18
  rolesNamedBy,
19
19
  sqlSkeleton,
20
20
  statementSubject
21
- } from "./chunk-XBXMOGI3.js";
21
+ } from "./chunk-WNZCOYOK.js";
22
22
  import {
23
23
  loadSnapshot
24
- } from "./chunk-67JVGG3G.js";
24
+ } from "./chunk-3SEVACCT.js";
25
25
  import {
26
26
  isCommentOnly,
27
27
  isPsqlMetaCommand,
28
28
  splitSqlStatements,
29
29
  stripPsqlMetaCommands
30
- } from "./chunk-YE3RQLCR.js";
30
+ } from "./chunk-YYS4FJ23.js";
31
31
  import {
32
32
  newPgClient,
33
33
  pgQuery,
@@ -900,4 +900,4 @@ export {
900
900
  previewMigrationRestore,
901
901
  summarizeStatement
902
902
  };
903
- //# sourceMappingURL=chunk-2ELJ46KR.js.map
903
+ //# sourceMappingURL=chunk-KBZUTGGF.js.map
@@ -22,7 +22,7 @@ import { formatWithOptions } from "util";
22
22
  import { Command } from "@oclif/core";
23
23
 
24
24
  // src/run-log.ts
25
- import { readFile, writeFile, mkdir, appendFile } from "fs/promises";
25
+ import { readFile, writeFile, mkdir, appendFile, chmod } from "fs/promises";
26
26
  import { homedir } from "os";
27
27
  import { join } from "path";
28
28
  function runLogPath() {
@@ -33,10 +33,12 @@ function runLogDir() {
33
33
  }
34
34
  async function appendRunLog(entry) {
35
35
  const dir = runLogDir();
36
- await mkdir(dir, { recursive: true });
36
+ await mkdir(dir, { recursive: true, mode: 448 });
37
37
  const path = runLogPath();
38
38
  const line = JSON.stringify(entry) + "\n";
39
- await appendFile(path, line, "utf8");
39
+ await appendFile(path, line, { encoding: "utf8", mode: 384 });
40
+ await chmod(path, 384).catch(() => {
41
+ });
40
42
  pruneRunLog(path).catch(() => {
41
43
  });
42
44
  }
@@ -60,7 +62,7 @@ async function pruneRunLog(path) {
60
62
  const lines = raw.split("\n").filter(Boolean);
61
63
  if (lines.length <= RUN_LOG_MAX_ENTRIES) return;
62
64
  const trimmed = lines.slice(lines.length - RUN_LOG_MAX_ENTRIES);
63
- await writeFile(path, trimmed.join("\n") + "\n", "utf8");
65
+ await writeFile(path, trimmed.join("\n") + "\n", { encoding: "utf8", mode: 384 });
64
66
  } catch {
65
67
  }
66
68
  }
@@ -211,4 +213,4 @@ export {
211
213
  readRunLog,
212
214
  BaseCommand
213
215
  };
214
- //# sourceMappingURL=chunk-CKH6J7DI.js.map
216
+ //# sourceMappingURL=chunk-TU5UIODX.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  targetFingerprint,
3
3
  writtenAgainst
4
- } from "./chunk-LV44B3BX.js";
4
+ } from "./chunk-YQLVRHJA.js";
5
5
  import {
6
6
  ensureMigrationsTable,
7
7
  getAppliedVersions,
@@ -10,13 +10,13 @@ import {
10
10
  } from "./chunk-HWRRFF55.js";
11
11
  import {
12
12
  isDestructiveSql
13
- } from "./chunk-XBXMOGI3.js";
13
+ } from "./chunk-WNZCOYOK.js";
14
14
  import {
15
15
  BaseCommand
16
- } from "./chunk-CKH6J7DI.js";
16
+ } from "./chunk-TU5UIODX.js";
17
17
  import {
18
18
  splitSqlStatements
19
- } from "./chunk-YE3RQLCR.js";
19
+ } from "./chunk-YYS4FJ23.js";
20
20
  import {
21
21
  DEFAULT_IGNORE_SCHEMAS,
22
22
  bold,
@@ -180,4 +180,4 @@ export {
180
180
  findDestructiveStatements,
181
181
  truncateSql
182
182
  };
183
- //# sourceMappingURL=chunk-PH2PU4NS.js.map
183
+ //# sourceMappingURL=chunk-UUDXVYEI.js.map
@@ -7,9 +7,10 @@ import {
7
7
  isCommentOnly,
8
8
  matchesGlob,
9
9
  parseFlagList,
10
+ pgToolConnection,
10
11
  resolvePgDumpPath,
11
12
  splitSqlStatements
12
- } from "./chunk-YE3RQLCR.js";
13
+ } from "./chunk-YYS4FJ23.js";
13
14
  import {
14
15
  Check,
15
16
  heldSnapshot,
@@ -1009,37 +1010,113 @@ function withoutDropStatements(sql) {
1009
1010
  if (!/\bDROP\b/i.test(sql)) return sql;
1010
1011
  return splitSqlStatements(sql).filter((s) => !/^\s*DROP\b/i.test(sqlSkeleton(s))).join("\n");
1011
1012
  }
1012
- function nextReady(remaining, nodes, done) {
1013
- const ready = remaining.filter((i) => isSatisfied(nodes[i].after, done));
1014
- const first = (from, key) => from.reduce((best, i) => best === void 0 || key(nodes[i]) < key(nodes[best]) ? i : best, void 0);
1015
- const head = first(ready.filter((i) => nodes[i].rank !== void 0), (n) => n.rank);
1016
- const free = first(ready.filter((i) => nodes[i].rank === void 0), (n) => n.phase);
1017
- if (head === void 0 || free === void 0) return head ?? free ?? remaining[0];
1018
- const sequence = Math.min(...remaining.filter((i) => nodes[i].rank !== void 0 && !DROP_PHASES.has(nodes[i].phase)).map((i) => nodes[i].phase));
1019
- return nodes[free].phase < sequence ? free : head;
1020
- }
1021
- function isSatisfied(after, done) {
1022
- for (const dep of after) {
1023
- if (!done.has(dep)) return false;
1013
+ function orderNodes(nodes) {
1014
+ const n = nodes.length;
1015
+ const waiting = new Array(n);
1016
+ const dependents = Array.from({ length: n }, () => []);
1017
+ for (let i = 0; i < n; i++) {
1018
+ waiting[i] = nodes[i].after.size;
1019
+ for (const dep of nodes[i].after) dependents[dep].push(i);
1020
+ }
1021
+ const ranked = new MinHeap((a, b) => nodes[a].rank - nodes[b].rank || a - b);
1022
+ const free = new MinHeap((a, b) => nodes[a].phase - nodes[b].phase || a - b);
1023
+ const enqueue = (i) => (nodes[i].rank !== void 0 ? ranked : free).push(i);
1024
+ const sequenceLeft = /* @__PURE__ */ new Map();
1025
+ for (const node of nodes) {
1026
+ if (node.rank !== void 0 && !DROP_PHASES.has(node.phase)) {
1027
+ sequenceLeft.set(node.phase, (sequenceLeft.get(node.phase) ?? 0) + 1);
1028
+ }
1029
+ }
1030
+ const earliestInSequence = () => {
1031
+ let min = Infinity;
1032
+ for (const [phase, count] of sequenceLeft) if (count > 0 && phase < min) min = phase;
1033
+ return min;
1034
+ };
1035
+ const done = new Array(n).fill(false);
1036
+ for (let i = 0; i < n; i++) if (waiting[i] === 0) enqueue(i);
1037
+ let lowest = 0;
1038
+ const order = [];
1039
+ const peek = (heap) => {
1040
+ while (heap.size > 0 && done[heap.peek()]) heap.pop();
1041
+ return heap.size > 0 ? heap.peek() : void 0;
1042
+ };
1043
+ while (order.length < n) {
1044
+ const head = peek(ranked);
1045
+ const other = peek(free);
1046
+ let next;
1047
+ if (head === void 0 || other === void 0) {
1048
+ if (head !== void 0 || other !== void 0) {
1049
+ next = head ?? other;
1050
+ } else {
1051
+ while (done[lowest]) lowest++;
1052
+ next = lowest;
1053
+ }
1054
+ } else {
1055
+ next = nodes[other].phase < earliestInSequence() ? other : head;
1056
+ }
1057
+ done[next] = true;
1058
+ order.push(next);
1059
+ const node = nodes[next];
1060
+ if (node.rank !== void 0 && !DROP_PHASES.has(node.phase)) {
1061
+ sequenceLeft.set(node.phase, sequenceLeft.get(node.phase) - 1);
1062
+ }
1063
+ for (const d of dependents[next]) {
1064
+ if (--waiting[d] === 0 && !done[d]) enqueue(d);
1065
+ }
1066
+ }
1067
+ return order;
1068
+ }
1069
+ var MinHeap = class {
1070
+ constructor(compare) {
1071
+ this.compare = compare;
1072
+ }
1073
+ compare;
1074
+ items = [];
1075
+ get size() {
1076
+ return this.items.length;
1077
+ }
1078
+ peek() {
1079
+ return this.items[0];
1080
+ }
1081
+ push(item) {
1082
+ const items = this.items;
1083
+ items.push(item);
1084
+ let i = items.length - 1;
1085
+ while (i > 0) {
1086
+ const parent = i - 1 >> 1;
1087
+ if (this.compare(items[i], items[parent]) >= 0) break;
1088
+ [items[i], items[parent]] = [items[parent], items[i]];
1089
+ i = parent;
1090
+ }
1091
+ }
1092
+ pop() {
1093
+ const items = this.items;
1094
+ const top = items[0];
1095
+ const last = items.pop();
1096
+ if (items.length > 0) {
1097
+ items[0] = last;
1098
+ let i = 0;
1099
+ for (; ; ) {
1100
+ const l = 2 * i + 1;
1101
+ const r = l + 1;
1102
+ let m = i;
1103
+ if (l < items.length && this.compare(items[l], items[m]) < 0) m = l;
1104
+ if (r < items.length && this.compare(items[r], items[m]) < 0) m = r;
1105
+ if (m === i) break;
1106
+ [items[i], items[m]] = [items[m], items[i]];
1107
+ i = m;
1108
+ }
1109
+ }
1110
+ return top;
1024
1111
  }
1025
- return true;
1026
- }
1112
+ };
1027
1113
  function orderStatements(items, sqlOf, rankOf = () => void 0) {
1028
1114
  if (items.length < 2) return [...items];
1029
1115
  const texts = items.map(sqlOf);
1030
1116
  const provides = texts.map(providedNames);
1031
1117
  const nodes = texts.map((sql, i) => ({ phase: statementPhase(sql), rank: rankOf(items[i]), after: /* @__PURE__ */ new Set() }));
1032
1118
  linkDependencies(nodes, texts, provides);
1033
- const done = /* @__PURE__ */ new Set();
1034
- let remaining = texts.map((_, i) => i);
1035
- const ordered = [];
1036
- while (remaining.length > 0) {
1037
- const next = nextReady(remaining, nodes, done);
1038
- ordered.push(items[next]);
1039
- done.add(next);
1040
- remaining = remaining.filter((i) => i !== next);
1041
- }
1042
- return ordered;
1119
+ return orderNodes(nodes).map((i) => items[i]);
1043
1120
  }
1044
1121
  function splitQualified(identifier) {
1045
1122
  const parts = identifier.match(/"[^"]+"|[\w$]+/g) ?? [];
@@ -1212,8 +1289,9 @@ function snapshotArgs(sourceUrl, targetUrl) {
1212
1289
  function buildDbDiffArgs(options, outputFile) {
1213
1290
  const args = [
1214
1291
  "diff",
1215
- `--server1-url=${options.sourceUrl}`,
1216
- `--server2-url=${options.targetUrl}`,
1292
+ // A process's arguments are readable by every user on the machine; its
1293
+ // environment only by its own user. See dbdiffUrlEnv().
1294
+ ...options.urlsOnCommandLine ? [`--server1-url=${options.sourceUrl}`, `--server2-url=${options.targetUrl}`] : [],
1217
1295
  `--type=${options.type}`,
1218
1296
  // Was hardcoded to 'both', silently ignoring options.include. Every caller
1219
1297
  // passes 'both' (sqlToIssues pairs each UP statement with its DOWN
@@ -1253,6 +1331,10 @@ function buildDbDiffArgs(options, outputFile) {
1253
1331
  }
1254
1332
  return args;
1255
1333
  }
1334
+ function dbdiffUrlEnv(options) {
1335
+ if (options.urlsOnCommandLine) return {};
1336
+ return { DBDIFF_SERVER1_URL: options.sourceUrl, DBDIFF_SERVER2_URL: options.targetUrl };
1337
+ }
1256
1338
  function attachProgress(running, onProgress) {
1257
1339
  if (!onProgress) return;
1258
1340
  try {
@@ -1290,7 +1372,7 @@ async function runDbDiff(options) {
1290
1372
  const running = execFileAsync(command, args, {
1291
1373
  timeout: timeoutMs,
1292
1374
  maxBuffer: DBDIFF_MAX_BUFFER,
1293
- ...Object.keys(pgTools).length ? { env: { ...process.env, ...pgTools } } : {}
1375
+ env: { ...process.env, ...pgTools, ...dbdiffUrlEnv(options) }
1294
1376
  });
1295
1377
  attachProgress(running, options.onProgress);
1296
1378
  const { stdout } = await running;
@@ -1310,6 +1392,9 @@ async function runDbDiff(options) {
1310
1392
  if (options.units !== false && /"--units" option does not exist/.test(`${combined} ${stdout}`)) {
1311
1393
  return runDbDiff({ ...options, units: false });
1312
1394
  }
1395
+ if (!options.urlsOnCommandLine && /Missing input argument/.test(`${combined} ${stdout}`)) {
1396
+ return runDbDiff({ ...options, urlsOnCommandLine: true });
1397
+ }
1313
1398
  if (dbdiffNotInstalled(errObj.code, stderr)) {
1314
1399
  throw new DiagnosticError(
1315
1400
  "@dbdiff/cli is not installed. Install it with: npm install @dbdiff/cli"
@@ -1539,12 +1624,45 @@ function platformExtensionMoves(issues) {
1539
1624
  });
1540
1625
  }
1541
1626
  var quoteIdent2 = (name) => /^[a-z_][a-z0-9_$]*$/.test(name) ? name : `"${name.replace(/"/g, '""')}"`;
1542
- function withPlatformExtensionCalls(issues, moves, functions) {
1543
- const rules = moves.flatMap((move) => [...functions.get(move.name) ?? []].map((fn) => ({ move, fn })));
1627
+ var accepts = (fn, args) => args >= fn.minArgs && args <= fn.maxArgs;
1628
+ function argumentCount(sql, mask, open) {
1629
+ let depth = 0;
1630
+ let commas = 0;
1631
+ let empty = true;
1632
+ for (let i = open; i < mask.length; i++) {
1633
+ const c = mask[i];
1634
+ if (c === "(" || c === "[") {
1635
+ depth++;
1636
+ if (depth > 1) empty = false;
1637
+ continue;
1638
+ }
1639
+ if (c === ")" || c === "]") {
1640
+ if (--depth === 0) return empty ? 0 : commas + 1;
1641
+ continue;
1642
+ }
1643
+ if (depth === 1 && c === ",") commas++;
1644
+ if (depth >= 1 && !/\s/.test(sql[i])) empty = false;
1645
+ }
1646
+ return void 0;
1647
+ }
1648
+ var DEFINES = /\bCREATE\s+(?:OR\s+REPLACE\s+)?(?:FUNCTION|PROCEDURE|AGGREGATE)\s*$/i;
1649
+ function withPlatformExtensionCalls(issues, moves, functions, shadows = []) {
1650
+ const rules = moves.flatMap((move) => (functions.get(move.name) ?? []).map((fn) => ({ move, fn })));
1544
1651
  if (!rules.length) return issues;
1545
1652
  const nameRe = String.raw`("(?:[^"]|"")+"|[\w$]+)`;
1546
1653
  const call = new RegExp(String.raw`${nameRe}(\s*\.\s*)${nameRe}(?=\s*\()`, "g");
1547
1654
  const unq = (part) => part.startsWith('"') ? part.slice(1, -1).replace(/""/g, '"') : part.toLowerCase();
1655
+ const defined = [...shadows];
1656
+ for (const issue of issues) {
1657
+ for (const sql of issue.sql ? [issue.sql.up, issue.sql.down] : []) {
1658
+ const mask = codeMask(sql);
1659
+ for (const m of mask.matchAll(call)) {
1660
+ if (!DEFINES.test(mask.slice(0, m.index))) continue;
1661
+ const args = argumentCount(sql, mask, mask.indexOf("(", m.index + m[0].length));
1662
+ if (args !== void 0) defined.push({ schema: unq(m[1]), name: unq(m[3]), minArgs: args, maxArgs: args });
1663
+ }
1664
+ }
1665
+ }
1548
1666
  const rewrite = (sql, seen) => {
1549
1667
  const mask = codeMask(sql);
1550
1668
  let out = "";
@@ -1552,8 +1670,12 @@ function withPlatformExtensionCalls(issues, moves, functions) {
1552
1670
  for (const m of mask.matchAll(call)) {
1553
1671
  const schema = unq(m[1]);
1554
1672
  const fn = unq(m[3]);
1555
- const rule = rules.find((r) => r.move.sourceSchema === schema && r.fn === fn);
1673
+ if (DEFINES.test(mask.slice(0, m.index))) continue;
1674
+ const args = argumentCount(sql, mask, mask.indexOf("(", m.index + m[0].length));
1675
+ if (args === void 0) continue;
1676
+ const rule = rules.find((r) => r.move.sourceSchema === schema && r.fn.name === fn && accepts(r.fn, args));
1556
1677
  if (!rule) continue;
1678
+ if (defined.some((d) => d.schema === schema && d.name === fn && accepts(d, args))) continue;
1557
1679
  out += sql.slice(at, m.index) + quoteIdent2(rule.move.targetSchema) + m[2] + sql.slice(m.index + m[1].length + m[2].length, m.index + m[0].length);
1558
1680
  at = m.index + m[0].length;
1559
1681
  seen.add(`${quoteIdent2(schema)}.${quoteIdent2(fn)}() \u2192 ${quoteIdent2(rule.move.targetSchema)}.${quoteIdent2(fn)}()`);
@@ -2923,8 +3045,10 @@ async function sampleInto(psql, fromUrl, intoUrl, schemas, limit) {
2923
3045
  }
2924
3046
  function pipeCopy(psql, fromUrl, intoUrl, out, into) {
2925
3047
  return new Promise((resolve, reject) => {
2926
- const reader = spawn(psql, [fromUrl, "-X", "-q", "-v", "ON_ERROR_STOP=1", "-c", out], { stdio: ["ignore", "pipe", "pipe"] });
2927
- const writer = spawn(psql, [intoUrl, "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", "-"], { stdio: ["pipe", "pipe", "pipe"] });
3048
+ const reading = pgToolConnection(fromUrl);
3049
+ const writing = pgToolConnection(intoUrl);
3050
+ const reader = spawn(psql, [reading.url, "-X", "-q", "-v", "ON_ERROR_STOP=1", "-c", out], { stdio: ["ignore", "pipe", "pipe"], env: reading.env });
3051
+ const writer = spawn(psql, [writing.url, "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", "-"], { stdio: ["pipe", "pipe", "pipe"], env: writing.env });
2928
3052
  let stderr = "";
2929
3053
  reader.stderr.on("data", (d) => {
2930
3054
  stderr += d.toString();
@@ -3202,8 +3326,9 @@ async function copyStructure(fromUrl, intoUrl, schemas, tools, migratingFrom) {
3202
3326
  if (present.has(name) && !supporting.includes(name)) supporting.push(name);
3203
3327
  }
3204
3328
  }
3329
+ const from = pgToolConnection(fromUrl);
3205
3330
  const dumpArgs = [
3206
- fromUrl,
3331
+ from.url,
3207
3332
  "--schema-only",
3208
3333
  "--no-owner",
3209
3334
  "--no-privileges",
@@ -3211,7 +3336,8 @@ async function copyStructure(fromUrl, intoUrl, schemas, tools, migratingFrom) {
3211
3336
  ];
3212
3337
  const { stdout: structure } = await exec(tools.pgDump, dumpArgs, {
3213
3338
  maxBuffer: 256 * 1024 * 1024,
3214
- timeout: 3e5
3339
+ timeout: 3e5,
3340
+ env: from.env
3215
3341
  });
3216
3342
  const { sql: replayable } = dropUnsupportedSetStatements(
3217
3343
  tolerateExistingSchemas(structure),
@@ -3290,8 +3416,10 @@ function runSql(psqlPath, dbUrl, sql) {
3290
3416
  const trimmed = sql.trim();
3291
3417
  if (!trimmed) return Promise.resolve();
3292
3418
  return new Promise((resolve, reject) => {
3293
- const child = spawn2(psqlPath, [dbUrl, "-v", "ON_ERROR_STOP=1", "-q", "-f", "-"], {
3294
- stdio: ["pipe", "pipe", "pipe"]
3419
+ const conn = pgToolConnection(dbUrl);
3420
+ const child = spawn2(psqlPath, [conn.url, "-v", "ON_ERROR_STOP=1", "-q", "-f", "-"], {
3421
+ stdio: ["pipe", "pipe", "pipe"],
3422
+ env: conn.env
3295
3423
  });
3296
3424
  let stderr = "";
3297
3425
  child.stderr.on("data", (d) => {
@@ -3465,4 +3593,4 @@ export {
3465
3593
  residualHeldBack,
3466
3594
  proofScope
3467
3595
  };
3468
- //# sourceMappingURL=chunk-XBXMOGI3.js.map
3596
+ //# sourceMappingURL=chunk-WNZCOYOK.js.map
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  migrationsDir,
3
3
  writeMigrationFile
4
- } from "./chunk-ZBQLDCYV.js";
4
+ } from "./chunk-CRUFF6K5.js";
5
5
  import {
6
6
  createDefaultRegistry,
7
7
  proveBeforeApply,
8
8
  scan
9
- } from "./chunk-AUNVMGTR.js";
9
+ } from "./chunk-EGXQ37PA.js";
10
10
  import {
11
11
  CHECK_NAMES,
12
12
  promote
13
- } from "./chunk-XBXMOGI3.js";
13
+ } from "./chunk-WNZCOYOK.js";
14
14
  import {
15
15
  captureSnapshot,
16
16
  unrestorableSchema
17
- } from "./chunk-67JVGG3G.js";
17
+ } from "./chunk-3SEVACCT.js";
18
18
  import {
19
19
  checkConnection
20
20
  } from "./chunk-RC7ZU7OV.js";
@@ -530,4 +530,4 @@ export {
530
530
  clearLastScanResult,
531
531
  createServer
532
532
  };
533
- //# sourceMappingURL=chunk-BLP7UO6C.js.map
533
+ //# sourceMappingURL=chunk-XTSFAUXI.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  comparedSchemas,
3
3
  fingerprint
4
- } from "./chunk-XBXMOGI3.js";
4
+ } from "./chunk-WNZCOYOK.js";
5
5
 
6
6
  // src/written-against.ts
7
7
  import { createHash } from "crypto";
@@ -24,4 +24,4 @@ export {
24
24
  writtenAgainstLine,
25
25
  writtenAgainst
26
26
  };
27
- //# sourceMappingURL=chunk-LV44B3BX.js.map
27
+ //# sourceMappingURL=chunk-YQLVRHJA.js.map
@@ -354,6 +354,26 @@ function getInstallInstructions(majorVersion) {
354
354
  }
355
355
  }
356
356
 
357
+ // src/utils/pg-env.ts
358
+ function pgToolConnection(url, base = process.env) {
359
+ let parsed;
360
+ try {
361
+ parsed = new URL(url);
362
+ } catch {
363
+ return { url, env: base };
364
+ }
365
+ if (!/^postgres(?:ql)?:$/.test(parsed.protocol)) return { url, env: base };
366
+ const inQuery = parsed.searchParams.get("password");
367
+ const password = parsed.password ? decodeURIComponent(parsed.password) : inQuery;
368
+ if (password === null || password === "") return { url, env: base };
369
+ parsed.password = "";
370
+ if (inQuery !== null) {
371
+ const rest = parsed.search.slice(1).split("&").filter((p) => !/^password(?:=|$)/.test(p));
372
+ parsed.search = rest.length ? `?${rest.join("&")}` : "";
373
+ }
374
+ return { url: parsed.toString(), env: { ...base, PGPASSWORD: password } };
375
+ }
376
+
357
377
  export {
358
378
  splitSqlStatements,
359
379
  isCommentOnly,
@@ -370,6 +390,7 @@ export {
370
390
  describeMissingPgDump,
371
391
  getServerMajorVersion,
372
392
  dbdiffPgToolsEnv,
373
- checkPgDumpCompat
393
+ checkPgDumpCompat,
394
+ pgToolConnection
374
395
  };
375
- //# sourceMappingURL=chunk-YE3RQLCR.js.map
396
+ //# sourceMappingURL=chunk-YYS4FJ23.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-RQCXGO37.js";
4
4
  import {
5
5
  BaseCommand
6
- } from "../chunk-CKH6J7DI.js";
6
+ } from "../chunk-TU5UIODX.js";
7
7
  import {
8
8
  addBranchToManifest,
9
9
  cloneRemoteToLocal,
@@ -13,14 +13,14 @@ import {
13
13
  maintenanceUrl,
14
14
  reconcileClones,
15
15
  replaceDbName
16
- } from "../chunk-YDISW5X7.js";
16
+ } from "../chunk-2XMRTAFX.js";
17
17
  import {
18
18
  captureSnapshot,
19
19
  formatSnapshotLayers
20
- } from "../chunk-67JVGG3G.js";
20
+ } from "../chunk-3SEVACCT.js";
21
21
  import {
22
22
  checkPgDumpCompat
23
- } from "../chunk-YE3RQLCR.js";
23
+ } from "../chunk-YYS4FJ23.js";
24
24
  import {
25
25
  DEFAULT_LOCAL_PORT,
26
26
  LOCAL_PG_PASSWORD,
@@ -2,16 +2,16 @@ import {
2
2
  Diff,
3
3
  inertApplyFlags,
4
4
  rollbackHint
5
- } from "../chunk-AJ53RPJS.js";
5
+ } from "../chunk-CUGDLO2L.js";
6
6
  import "../chunk-Q43MN6NE.js";
7
- import "../chunk-FFRGDQMV.js";
8
- import "../chunk-AUNVMGTR.js";
9
- import "../chunk-XBXMOGI3.js";
7
+ import "../chunk-EB6PCOIL.js";
8
+ import "../chunk-EGXQ37PA.js";
9
+ import "../chunk-WNZCOYOK.js";
10
10
  import "../chunk-RQCXGO37.js";
11
- import "../chunk-CKH6J7DI.js";
12
- import "../chunk-YDISW5X7.js";
13
- import "../chunk-67JVGG3G.js";
14
- import "../chunk-YE3RQLCR.js";
11
+ import "../chunk-TU5UIODX.js";
12
+ import "../chunk-2XMRTAFX.js";
13
+ import "../chunk-3SEVACCT.js";
14
+ import "../chunk-YYS4FJ23.js";
15
15
  import "../chunk-RC7ZU7OV.js";
16
16
  import "../chunk-KHXEES2M.js";
17
17
  import "../chunk-SQ52YBKK.js";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  Diff
3
- } from "../chunk-AJ53RPJS.js";
3
+ } from "../chunk-CUGDLO2L.js";
4
4
  import "../chunk-Q43MN6NE.js";
5
- import "../chunk-FFRGDQMV.js";
6
- import "../chunk-AUNVMGTR.js";
7
- import "../chunk-XBXMOGI3.js";
5
+ import "../chunk-EB6PCOIL.js";
6
+ import "../chunk-EGXQ37PA.js";
7
+ import "../chunk-WNZCOYOK.js";
8
8
  import "../chunk-RQCXGO37.js";
9
- import "../chunk-CKH6J7DI.js";
10
- import "../chunk-YDISW5X7.js";
11
- import "../chunk-67JVGG3G.js";
12
- import "../chunk-YE3RQLCR.js";
9
+ import "../chunk-TU5UIODX.js";
10
+ import "../chunk-2XMRTAFX.js";
11
+ import "../chunk-3SEVACCT.js";
12
+ import "../chunk-YYS4FJ23.js";
13
13
  import "../chunk-RC7ZU7OV.js";
14
14
  import "../chunk-KHXEES2M.js";
15
15
  import "../chunk-SQ52YBKK.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  createServer
3
- } from "../chunk-BLP7UO6C.js";
4
- import "../chunk-ZBQLDCYV.js";
5
- import "../chunk-LV44B3BX.js";
6
- import "../chunk-AUNVMGTR.js";
7
- import "../chunk-XBXMOGI3.js";
8
- import "../chunk-67JVGG3G.js";
9
- import "../chunk-YE3RQLCR.js";
3
+ } from "../chunk-XTSFAUXI.js";
4
+ import "../chunk-CRUFF6K5.js";
5
+ import "../chunk-YQLVRHJA.js";
6
+ import "../chunk-EGXQ37PA.js";
7
+ import "../chunk-WNZCOYOK.js";
8
+ import "../chunk-3SEVACCT.js";
9
+ import "../chunk-YYS4FJ23.js";
10
10
  import "../chunk-RC7ZU7OV.js";
11
11
  import {
12
12
  installProcessGuard,
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunk-HWRRFF55.js";
4
4
  import {
5
5
  BaseCommand
6
- } from "../../chunk-CKH6J7DI.js";
6
+ } from "../../chunk-TU5UIODX.js";
7
7
  import "../../chunk-RC7ZU7OV.js";
8
8
  import "../../chunk-KHXEES2M.js";
9
9
  import {
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  truncateSql
3
- } from "../../chunk-PH2PU4NS.js";
3
+ } from "../../chunk-UUDXVYEI.js";
4
4
  import {
5
5
  generateTimestamp,
6
6
  writeMigrationFile
7
- } from "../../chunk-ZBQLDCYV.js";
8
- import "../../chunk-LV44B3BX.js";
7
+ } from "../../chunk-CRUFF6K5.js";
8
+ import "../../chunk-YQLVRHJA.js";
9
9
  import "../../chunk-HWRRFF55.js";
10
- import "../../chunk-XBXMOGI3.js";
10
+ import "../../chunk-WNZCOYOK.js";
11
11
  import {
12
12
  BaseCommand
13
- } from "../../chunk-CKH6J7DI.js";
13
+ } from "../../chunk-TU5UIODX.js";
14
14
  import {
15
15
  slugify
16
- } from "../../chunk-YE3RQLCR.js";
16
+ } from "../../chunk-YYS4FJ23.js";
17
17
  import "../../chunk-RC7ZU7OV.js";
18
18
  import "../../chunk-KHXEES2M.js";
19
19
  import {
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunk-HWRRFF55.js";
4
4
  import {
5
5
  BaseCommand
6
- } from "../../chunk-CKH6J7DI.js";
6
+ } from "../../chunk-TU5UIODX.js";
7
7
  import {
8
8
  pgQuery,
9
9
  readLocalMigrations
@@ -2,12 +2,12 @@ import {
2
2
  MigrateRun,
3
3
  findDestructiveStatements,
4
4
  truncateSql
5
- } from "../../chunk-PH2PU4NS.js";
6
- import "../../chunk-LV44B3BX.js";
5
+ } from "../../chunk-UUDXVYEI.js";
6
+ import "../../chunk-YQLVRHJA.js";
7
7
  import "../../chunk-HWRRFF55.js";
8
- import "../../chunk-XBXMOGI3.js";
9
- import "../../chunk-CKH6J7DI.js";
10
- import "../../chunk-YE3RQLCR.js";
8
+ import "../../chunk-WNZCOYOK.js";
9
+ import "../../chunk-TU5UIODX.js";
10
+ import "../../chunk-YYS4FJ23.js";
11
11
  import "../../chunk-RC7ZU7OV.js";
12
12
  import "../../chunk-KHXEES2M.js";
13
13
  import "../../chunk-SQ52YBKK.js";
@@ -5,7 +5,7 @@ import {
5
5
  BaseCommand,
6
6
  readRunLog,
7
7
  runLogPath
8
- } from "../chunk-CKH6J7DI.js";
8
+ } from "../chunk-TU5UIODX.js";
9
9
  import "../chunk-RC7ZU7OV.js";
10
10
  import "../chunk-KHXEES2M.js";
11
11
  import {
@@ -5,21 +5,21 @@ import {
5
5
  restoreFromMigrations,
6
6
  restoreFromSnapshot,
7
7
  summarizeStatement
8
- } from "../chunk-2ELJ46KR.js";
9
- import "../chunk-C32M67YH.js";
8
+ } from "../chunk-KBZUTGGF.js";
9
+ import "../chunk-4TBYWXUK.js";
10
10
  import "../chunk-HWRRFF55.js";
11
- import "../chunk-XBXMOGI3.js";
11
+ import "../chunk-WNZCOYOK.js";
12
12
  import {
13
13
  renderTip
14
14
  } from "../chunk-RQCXGO37.js";
15
15
  import {
16
16
  BaseCommand
17
- } from "../chunk-CKH6J7DI.js";
17
+ } from "../chunk-TU5UIODX.js";
18
18
  import {
19
19
  findLatestSnapshot,
20
20
  listSnapshots
21
- } from "../chunk-67JVGG3G.js";
22
- import "../chunk-YE3RQLCR.js";
21
+ } from "../chunk-3SEVACCT.js";
22
+ import "../chunk-YYS4FJ23.js";
23
23
  import "../chunk-RC7ZU7OV.js";
24
24
  import "../chunk-KHXEES2M.js";
25
25
  import {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  backup,
3
3
  listMigrationFiles
4
- } from "../chunk-C32M67YH.js";
4
+ } from "../chunk-4TBYWXUK.js";
5
5
  import {
6
6
  renderTip
7
7
  } from "../chunk-RQCXGO37.js";
8
8
  import {
9
9
  BaseCommand
10
- } from "../chunk-CKH6J7DI.js";
10
+ } from "../chunk-TU5UIODX.js";
11
11
  import {
12
12
  DEFAULT_KEEP_COUNT,
13
13
  captureSnapshot,
@@ -15,8 +15,8 @@ import {
15
15
  listSnapshots,
16
16
  pruneSnapshots,
17
17
  unrestorableSchema
18
- } from "../chunk-67JVGG3G.js";
19
- import "../chunk-YE3RQLCR.js";
18
+ } from "../chunk-3SEVACCT.js";
19
+ import "../chunk-YYS4FJ23.js";
20
20
  import "../chunk-RC7ZU7OV.js";
21
21
  import "../chunk-KHXEES2M.js";
22
22
  import {
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  Diff
3
- } from "../chunk-AJ53RPJS.js";
3
+ } from "../chunk-CUGDLO2L.js";
4
4
  import "../chunk-Q43MN6NE.js";
5
- import "../chunk-FFRGDQMV.js";
6
- import "../chunk-AUNVMGTR.js";
7
- import "../chunk-XBXMOGI3.js";
5
+ import "../chunk-EB6PCOIL.js";
6
+ import "../chunk-EGXQ37PA.js";
7
+ import "../chunk-WNZCOYOK.js";
8
8
  import "../chunk-RQCXGO37.js";
9
- import "../chunk-CKH6J7DI.js";
10
- import "../chunk-YDISW5X7.js";
11
- import "../chunk-67JVGG3G.js";
12
- import "../chunk-YE3RQLCR.js";
9
+ import "../chunk-TU5UIODX.js";
10
+ import "../chunk-2XMRTAFX.js";
11
+ import "../chunk-3SEVACCT.js";
12
+ import "../chunk-YYS4FJ23.js";
13
13
  import "../chunk-RC7ZU7OV.js";
14
14
  import "../chunk-KHXEES2M.js";
15
15
  import "../chunk-SQ52YBKK.js";
package/dist/index.js CHANGED
@@ -3,37 +3,37 @@ import {
3
3
  createServer,
4
4
  getLastScanResult,
5
5
  setLastScanResult
6
- } from "./chunk-BLP7UO6C.js";
6
+ } from "./chunk-XTSFAUXI.js";
7
7
  import {
8
8
  previewMigrationRestore,
9
9
  previewSnapshotRestore,
10
10
  restoreFromMigrations,
11
11
  restoreFromSnapshot
12
- } from "./chunk-2ELJ46KR.js";
12
+ } from "./chunk-KBZUTGGF.js";
13
13
  import {
14
14
  backup,
15
15
  listMigrationFiles,
16
16
  loadMigrations
17
- } from "./chunk-C32M67YH.js";
18
- import "./chunk-ZBQLDCYV.js";
19
- import "./chunk-LV44B3BX.js";
17
+ } from "./chunk-4TBYWXUK.js";
18
+ import "./chunk-CRUFF6K5.js";
19
+ import "./chunk-YQLVRHJA.js";
20
20
  import "./chunk-HWRRFF55.js";
21
21
  import {
22
22
  renderDetailed,
23
23
  renderSummary
24
- } from "./chunk-FFRGDQMV.js";
24
+ } from "./chunk-EB6PCOIL.js";
25
25
  import {
26
26
  CheckRegistry,
27
27
  computeScore,
28
28
  createDefaultRegistry,
29
29
  scan,
30
30
  summarize
31
- } from "./chunk-AUNVMGTR.js";
31
+ } from "./chunk-EGXQ37PA.js";
32
32
  import {
33
33
  CHECK_META,
34
34
  CHECK_NAMES,
35
35
  promote
36
- } from "./chunk-XBXMOGI3.js";
36
+ } from "./chunk-WNZCOYOK.js";
37
37
  import {
38
38
  BRANCH_DB_PREFIX,
39
39
  branchDbName,
@@ -42,14 +42,14 @@ import {
42
42
  listBranches,
43
43
  loadManifest,
44
44
  replaceDbName
45
- } from "./chunk-YDISW5X7.js";
45
+ } from "./chunk-2XMRTAFX.js";
46
46
  import {
47
47
  captureSnapshot,
48
48
  findLatestSnapshot,
49
49
  listSnapshots,
50
50
  loadSnapshot
51
- } from "./chunk-67JVGG3G.js";
52
- import "./chunk-YE3RQLCR.js";
51
+ } from "./chunk-3SEVACCT.js";
52
+ import "./chunk-YYS4FJ23.js";
53
53
  import {
54
54
  Check
55
55
  } from "./chunk-RC7ZU7OV.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akal/supaforge",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "mcpName": "io.github.akalsoftware/supaforge",
5
5
  "description": "Diff and sync your Supabase environments",
6
6
  "author": "Akal Software Ltd",
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@akal/pg-conformance": "~0.0.19",
59
- "@dbdiff/cli": "3.0.0-rc.37",
59
+ "@dbdiff/cli": "3.0.0-rc.39",
60
60
  "@modelcontextprotocol/sdk": "^1.32.1",
61
61
  "@oclif/core": "^5.1.12",
62
62
  "@supabase/supabase-js": "^2.103.0",