@akal/supaforge 0.0.31 → 0.0.33
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/LICENSE +21 -0
- package/README.md +29 -11
- package/dist/base-command.d.ts +1 -0
- package/dist/base-command.js +2 -2
- package/dist/{chunk-BHYLBKYD.js → chunk-2SELREHW.js} +5 -5
- package/dist/{chunk-5Z3SAIQS.js → chunk-3HGAV5CC.js} +97 -831
- package/dist/{chunk-XMYMIURR.js → chunk-4IVN7QVY.js} +119 -39
- package/dist/{chunk-NXRSAVRU.js → chunk-6LJERPUN.js} +28 -7
- package/dist/{chunk-4OU7KO5Y.js → chunk-6Q7MHFBM.js} +2 -2
- package/dist/{chunk-PARSNTBD.js → chunk-7NAZGZPV.js} +56 -25
- package/dist/{chunk-VOXZWQ3N.js → chunk-BUOWHE36.js} +372 -9
- package/dist/{chunk-TQJSQLWA.js → chunk-DMIWAJRB.js} +38 -10
- package/dist/{chunk-LQXF65MC.js → chunk-GEHPTPNZ.js} +3 -3
- package/dist/chunk-GZREXCQZ.js +207 -0
- package/dist/{chunk-YVDSR4GM.js → chunk-MIRLB5JM.js} +51 -23
- package/dist/{chunk-KIFJGON5.js → chunk-NTUASFQ3.js} +2 -2
- package/dist/{chunk-5QQBTLWO.js → chunk-ORQJVE57.js} +3 -3
- package/dist/{chunk-VMTBLHN2.js → chunk-SC2XHGIS.js} +2 -2
- package/dist/{chunk-X6V2GGDZ.js → chunk-SQPCWGQO.js} +388 -64
- package/dist/chunk-UWAVXC57.js +916 -0
- package/dist/commands/clone.js +10 -10
- package/dist/commands/diff.d.ts +16 -0
- package/dist/commands/diff.js +11 -12
- package/dist/commands/hukam.js +11 -12
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +18 -9
- package/dist/commands/migrate/baseline.js +3 -3
- package/dist/commands/migrate/create.js +5 -6
- package/dist/commands/migrate/list.js +4 -4
- package/dist/commands/migrate/run.js +5 -6
- package/dist/commands/report.js +3 -3
- package/dist/commands/restore.js +11 -13
- package/dist/commands/snapshot.js +6 -8
- package/dist/commands/sync.js +11 -12
- package/dist/index.d.ts +5 -0
- package/dist/index.js +16 -16
- package/package.json +10 -8
- package/bin/dev.js +0 -10
- package/dist/base-command.js.map +0 -1
- package/dist/chunk-4OU7KO5Y.js.map +0 -1
- package/dist/chunk-5QQBTLWO.js.map +0 -1
- package/dist/chunk-5Z3SAIQS.js.map +0 -1
- package/dist/chunk-6WAMNZLO.js.map +0 -1
- package/dist/chunk-BHYLBKYD.js.map +0 -1
- package/dist/chunk-BLKJWDTL.js.map +0 -1
- package/dist/chunk-DQQ5E563.js.map +0 -1
- package/dist/chunk-G2DIPIYU.js.map +0 -1
- package/dist/chunk-H5MJ5DFX.js +0 -16
- package/dist/chunk-H5MJ5DFX.js.map +0 -1
- package/dist/chunk-KIFJGON5.js.map +0 -1
- package/dist/chunk-LQXF65MC.js.map +0 -1
- package/dist/chunk-NXRSAVRU.js.map +0 -1
- package/dist/chunk-PARSNTBD.js.map +0 -1
- package/dist/chunk-RRMI5CZD.js +0 -376
- package/dist/chunk-RRMI5CZD.js.map +0 -1
- package/dist/chunk-SF3YA42C.js +0 -506
- package/dist/chunk-SF3YA42C.js.map +0 -1
- package/dist/chunk-TQJSQLWA.js.map +0 -1
- package/dist/chunk-VMTBLHN2.js.map +0 -1
- package/dist/chunk-VOXZWQ3N.js.map +0 -1
- package/dist/chunk-X6V2GGDZ.js.map +0 -1
- package/dist/chunk-XMYMIURR.js.map +0 -1
- package/dist/chunk-YVDSR4GM.js.map +0 -1
- package/dist/commands/clone.js.map +0 -1
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/help.js.map +0 -1
- package/dist/commands/hukam.js.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/migrate/baseline.js.map +0 -1
- package/dist/commands/migrate/create.js.map +0 -1
- package/dist/commands/migrate/list.js.map +0 -1
- package/dist/commands/migrate/run.js.map +0 -1
- package/dist/commands/report.js.map +0 -1
- package/dist/commands/restore.js.map +0 -1
- package/dist/commands/snapshot.js.map +0 -1
- package/dist/commands/sync.js.map +0 -1
- package/dist/help.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_MIGRATIONS_DIR,
|
|
3
|
+
Preflight,
|
|
4
|
+
describeFailure,
|
|
5
|
+
redactUrls
|
|
6
|
+
} from "./chunk-SQPCWGQO.js";
|
|
7
|
+
import {
|
|
8
|
+
RUN_LOG_DIR,
|
|
9
|
+
RUN_LOG_FILE,
|
|
10
|
+
RUN_LOG_MAX_ENTRIES,
|
|
11
|
+
loadConfig,
|
|
12
|
+
validateConfig,
|
|
13
|
+
validateSingleEnvConfig
|
|
14
|
+
} from "./chunk-6WAMNZLO.js";
|
|
15
|
+
|
|
16
|
+
// src/base-command.ts
|
|
17
|
+
import { formatWithOptions } from "util";
|
|
18
|
+
import { Command } from "@oclif/core";
|
|
19
|
+
|
|
20
|
+
// src/run-log.ts
|
|
21
|
+
import { readFile, writeFile, mkdir, appendFile } from "fs/promises";
|
|
22
|
+
import { homedir } from "os";
|
|
23
|
+
import { join } from "path";
|
|
24
|
+
function runLogPath() {
|
|
25
|
+
return join(homedir(), RUN_LOG_DIR, RUN_LOG_FILE);
|
|
26
|
+
}
|
|
27
|
+
function runLogDir() {
|
|
28
|
+
return join(homedir(), RUN_LOG_DIR);
|
|
29
|
+
}
|
|
30
|
+
async function appendRunLog(entry) {
|
|
31
|
+
const dir = runLogDir();
|
|
32
|
+
await mkdir(dir, { recursive: true });
|
|
33
|
+
const path = runLogPath();
|
|
34
|
+
const line = JSON.stringify(entry) + "\n";
|
|
35
|
+
await appendFile(path, line, "utf8");
|
|
36
|
+
pruneRunLog(path).catch(() => {
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async function readRunLog() {
|
|
40
|
+
try {
|
|
41
|
+
const raw = await readFile(runLogPath(), "utf8");
|
|
42
|
+
return raw.split("\n").filter(Boolean).map((line) => {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(line);
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}).filter((e) => e !== null);
|
|
49
|
+
} catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function pruneRunLog(path) {
|
|
54
|
+
try {
|
|
55
|
+
const raw = await readFile(path, "utf8");
|
|
56
|
+
const lines = raw.split("\n").filter(Boolean);
|
|
57
|
+
if (lines.length <= RUN_LOG_MAX_ENTRIES) return;
|
|
58
|
+
const trimmed = lines.slice(lines.length - RUN_LOG_MAX_ENTRIES);
|
|
59
|
+
await writeFile(path, trimmed.join("\n") + "\n", "utf8");
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function redactArgs(argv) {
|
|
64
|
+
return argv.map(redactUrls);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/base-command.ts
|
|
68
|
+
var BaseCommand = class extends Command {
|
|
69
|
+
_startTime = 0;
|
|
70
|
+
_logWritten = false;
|
|
71
|
+
_checkSummaries;
|
|
72
|
+
/**
|
|
73
|
+
* Under --json, stdout carries the JSON and nothing else: every other line a
|
|
74
|
+
* command prints — preflight checks, progress — goes to stderr. Before, the
|
|
75
|
+
* text came first and the output did not parse.
|
|
76
|
+
*/
|
|
77
|
+
log(message = "", ...args) {
|
|
78
|
+
if (this.argv.includes("--json")) {
|
|
79
|
+
process.stderr.write(formatWithOptions({ colors: false }, message, ...args) + "\n");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
super.log(message, ...args);
|
|
83
|
+
}
|
|
84
|
+
_jsonWritten = false;
|
|
85
|
+
/** The command's result as JSON, on stdout. */
|
|
86
|
+
json(value) {
|
|
87
|
+
this._jsonWritten = true;
|
|
88
|
+
process.stdout.write(JSON.stringify(value, null, 2) + "\n");
|
|
89
|
+
}
|
|
90
|
+
/** Call after scan() to attach per-check metadata to the run log entry. */
|
|
91
|
+
setCheckSummaries(summaries) {
|
|
92
|
+
this._checkSummaries = summaries;
|
|
93
|
+
}
|
|
94
|
+
async init() {
|
|
95
|
+
await super.init();
|
|
96
|
+
this._startTime = Date.now();
|
|
97
|
+
}
|
|
98
|
+
async catch(err) {
|
|
99
|
+
this._logWritten = true;
|
|
100
|
+
await this._writeRunLog("error", err.message);
|
|
101
|
+
if (this.argv?.includes("--json") && !this._jsonWritten && !isExitRequest(err)) {
|
|
102
|
+
this.json({ error: redactUrls(describeFailure(err)) });
|
|
103
|
+
}
|
|
104
|
+
return super.catch(err);
|
|
105
|
+
}
|
|
106
|
+
async finally(err) {
|
|
107
|
+
if (!this._logWritten) {
|
|
108
|
+
await this._writeRunLog(err ? "error" : "success", err?.message);
|
|
109
|
+
}
|
|
110
|
+
return super.finally(err);
|
|
111
|
+
}
|
|
112
|
+
async _writeRunLog(exitStatus, error) {
|
|
113
|
+
try {
|
|
114
|
+
const version = this.config?.version;
|
|
115
|
+
const argv = this.argv ?? [];
|
|
116
|
+
await appendRunLog({
|
|
117
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
118
|
+
command: this.id ?? "unknown",
|
|
119
|
+
args: redactArgs(argv),
|
|
120
|
+
durationMs: Date.now() - this._startTime,
|
|
121
|
+
exitStatus,
|
|
122
|
+
error,
|
|
123
|
+
version,
|
|
124
|
+
checkSummaries: this._checkSummaries
|
|
125
|
+
});
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Load config or exit with a helpful error. */
|
|
130
|
+
async loadConfigOrFail() {
|
|
131
|
+
try {
|
|
132
|
+
return await loadConfig();
|
|
133
|
+
} catch {
|
|
134
|
+
this.error(
|
|
135
|
+
'Could not load supaforge.config.json. Run "supaforge init" first.'
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Resolve a single environment by name.
|
|
141
|
+
* Accepts an explicit flag value or falls back to config.source.
|
|
142
|
+
*/
|
|
143
|
+
resolveEnv(config, envFlag) {
|
|
144
|
+
const envName = envFlag ?? config.source;
|
|
145
|
+
if (!envName) {
|
|
146
|
+
this.error('No environment specified. Use --env=<name> or set "source" in your config.');
|
|
147
|
+
}
|
|
148
|
+
const errors = validateSingleEnvConfig(config, envName);
|
|
149
|
+
if (errors.length > 0) {
|
|
150
|
+
this.error(`Invalid configuration:
|
|
151
|
+
${errors.join("\n ")}`);
|
|
152
|
+
}
|
|
153
|
+
return { envName, env: config.environments[envName] };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Validate a two-env (source + target) config.
|
|
157
|
+
* Applies flag overrides before validation.
|
|
158
|
+
*/
|
|
159
|
+
validateDualEnvConfig(config, sourceFlag, targetFlag) {
|
|
160
|
+
if (sourceFlag) config.source = sourceFlag;
|
|
161
|
+
if (targetFlag) config.target = targetFlag;
|
|
162
|
+
const errors = validateConfig(config);
|
|
163
|
+
if (errors.length > 0) {
|
|
164
|
+
this.error(`Invalid configuration:
|
|
165
|
+
${errors.join("\n ")}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** Redact password from a database URL for display. */
|
|
169
|
+
redactUrl(url) {
|
|
170
|
+
return url.replace(/:([^@/]{1,})@/, ":***@");
|
|
171
|
+
}
|
|
172
|
+
/** Resolve the migrations directory from config (with default fallback). */
|
|
173
|
+
resolveMigrationsDir(config) {
|
|
174
|
+
return config.checks?.migrations?.dir ?? DEFAULT_MIGRATIONS_DIR;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create, run, and enforce a preflight check.
|
|
178
|
+
* Returns the Preflight instance for commands that need to add custom checks.
|
|
179
|
+
* When `abortMessage` is provided, exits with an error if checks fail.
|
|
180
|
+
*/
|
|
181
|
+
createPreflight(title) {
|
|
182
|
+
return new Preflight(title, (m) => this.log(m));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Run a preflight and abort with a user-friendly message if it fails.
|
|
186
|
+
* Returns the report for commands that inspect individual check results.
|
|
187
|
+
*/
|
|
188
|
+
async runPreflight(preflight, commandName) {
|
|
189
|
+
const report = await preflight.run();
|
|
190
|
+
if (!report.passed) {
|
|
191
|
+
const reasons = report.checks.filter((c) => !c.passed).map((c) => `${c.label}: ${redactUrls(c.error ?? "failed")}`);
|
|
192
|
+
this.error(this.argv.includes("--json") ? `${commandName} aborted \u2014 ${reasons.join("; ")}` : `${commandName} aborted \u2014 fix the issues above first.`, { exit: 1 });
|
|
193
|
+
}
|
|
194
|
+
return report;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
function isExitRequest(err) {
|
|
198
|
+
const oclif = err?.oclif;
|
|
199
|
+
return typeof oclif?.exit === "number" && err.message?.startsWith("EEXIT");
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
runLogPath,
|
|
204
|
+
readRunLog,
|
|
205
|
+
BaseCommand
|
|
206
|
+
};
|
|
207
|
+
//# sourceMappingURL=chunk-GZREXCQZ.js.map
|
|
@@ -9,8 +9,9 @@ import {
|
|
|
9
9
|
pgQuery,
|
|
10
10
|
quoteIdent,
|
|
11
11
|
quoteLiteral,
|
|
12
|
-
quoteName
|
|
13
|
-
|
|
12
|
+
quoteName,
|
|
13
|
+
readOrAbsent
|
|
14
|
+
} from "./chunk-SQPCWGQO.js";
|
|
14
15
|
import {
|
|
15
16
|
DEFAULT_IGNORE_SCHEMAS,
|
|
16
17
|
MIGRATIONS_SUBDIR,
|
|
@@ -64,15 +65,18 @@ var VERSIONED_PG_DIRS = [
|
|
|
64
65
|
// RHEL / CentOS (PGDG)
|
|
65
66
|
];
|
|
66
67
|
async function resolvePgDumpPath(serverMajor) {
|
|
67
|
-
const defaultMajor = await getLocalPgDumpVersion();
|
|
68
|
-
if (defaultMajor !== null && defaultMajor >= serverMajor) {
|
|
69
|
-
return { path: "pg_dump", major: defaultMajor };
|
|
70
|
-
}
|
|
71
68
|
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
72
|
-
if (named
|
|
69
|
+
if (named) {
|
|
70
|
+
if (!existsSync(`${named}/pg_dump`)) {
|
|
71
|
+
throw new Error(`SUPAFORGE_PG_BIN is set to "${named}", which has no pg_dump`);
|
|
72
|
+
}
|
|
73
73
|
const major = await getPgDumpVersionAt(`${named}/pg_dump`);
|
|
74
74
|
if (major !== null && major >= serverMajor) return { path: `${named}/pg_dump`, major };
|
|
75
75
|
}
|
|
76
|
+
const defaultMajor = await getLocalPgDumpVersion();
|
|
77
|
+
if (defaultMajor !== null && defaultMajor >= serverMajor) {
|
|
78
|
+
return { path: "pg_dump", major: defaultMajor };
|
|
79
|
+
}
|
|
76
80
|
for (const v of versionsToCheck(serverMajor)) {
|
|
77
81
|
for (const tmpl of VERSIONED_PG_DIRS) {
|
|
78
82
|
const dir = tmpl.replace("{v}", String(v));
|
|
@@ -86,6 +90,16 @@ async function resolvePgDumpPath(serverMajor) {
|
|
|
86
90
|
}
|
|
87
91
|
return null;
|
|
88
92
|
}
|
|
93
|
+
async function describeMissingPgDump(neededMajor) {
|
|
94
|
+
const onPath = await getLocalPgDumpVersion();
|
|
95
|
+
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
96
|
+
const namedMajor = named ? await getPgDumpVersionAt(`${named}/pg_dump`) : null;
|
|
97
|
+
const found = [
|
|
98
|
+
onPath === null ? "none on PATH" : `${onPath} on PATH`,
|
|
99
|
+
...named ? [`${namedMajor ?? "none"} in SUPAFORGE_PG_BIN`] : []
|
|
100
|
+
].join(", ");
|
|
101
|
+
return `no pg_dump ${neededMajor} or newer (found: ${found}); set SUPAFORGE_PG_BIN to a directory of PostgreSQL ${neededMajor}+ client tools`;
|
|
102
|
+
}
|
|
89
103
|
function resolvePgRestorePath(pgDumpPath) {
|
|
90
104
|
if (pgDumpPath === "pg_dump") return "pg_restore";
|
|
91
105
|
return pgDumpPath.replace(/pg_dump$/, "pg_restore");
|
|
@@ -592,18 +606,10 @@ var RealtimeCheck = class extends Check {
|
|
|
592
606
|
return [...publicationIssues, ...policyIssues];
|
|
593
607
|
}
|
|
594
608
|
async fetchPolicies(dbUrl) {
|
|
595
|
-
|
|
596
|
-
return await this.queryFn(dbUrl, schemaPolicySql("realtime"));
|
|
597
|
-
} catch {
|
|
598
|
-
return [];
|
|
599
|
-
}
|
|
609
|
+
return readOrAbsent(async () => await this.queryFn(dbUrl, schemaPolicySql("realtime")), []);
|
|
600
610
|
}
|
|
601
611
|
async fetchPublications(dbUrl) {
|
|
602
|
-
|
|
603
|
-
return await this.queryFn(dbUrl, PUBLICATION_SQL);
|
|
604
|
-
} catch {
|
|
605
|
-
return [];
|
|
606
|
-
}
|
|
612
|
+
return readOrAbsent(async () => await this.queryFn(dbUrl, PUBLICATION_SQL), []);
|
|
607
613
|
}
|
|
608
614
|
};
|
|
609
615
|
var PLATFORM_PUBLICATIONS = ["supabase_realtime_messages_publication"];
|
|
@@ -1095,11 +1101,12 @@ async function captureRoleGrants(dir, dbUrl, queryFn) {
|
|
|
1095
1101
|
-- and it hides grants the connecting role takes no part in.
|
|
1096
1102
|
SELECT CASE WHEN a.grantee = 0 THEN 'PUBLIC' ELSE pg_get_userbyid(a.grantee) END AS grantee,
|
|
1097
1103
|
n.nspname AS table_schema, c.relname AS table_name, NULL::text AS column_name,
|
|
1098
|
-
a.privilege_type, a.is_grantable
|
|
1104
|
+
a.privilege_type, a.is_grantable,
|
|
1105
|
+
CASE c.relkind WHEN 'S' THEN 'SEQUENCE' ELSE '' END AS keyword, NULL::text AS args
|
|
1099
1106
|
FROM pg_class c
|
|
1100
1107
|
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
1101
1108
|
CROSS JOIN LATERAL aclexplode(c.relacl) a
|
|
1102
|
-
WHERE c.relacl IS NOT NULL AND c.relkind IN ('r', 'p', 'v', 'm', 'f')
|
|
1109
|
+
WHERE c.relacl IS NOT NULL AND c.relkind IN ('r', 'p', 'v', 'm', 'f', 'S')
|
|
1103
1110
|
AND a.grantee <> c.relowner
|
|
1104
1111
|
AND (a.grantee = 0 OR pg_get_userbyid(a.grantee) NOT IN (
|
|
1105
1112
|
'postgres','supabase_admin','authenticator','supabase_auth_admin',
|
|
@@ -1108,8 +1115,26 @@ async function captureRoleGrants(dir, dbUrl, queryFn) {
|
|
|
1108
1115
|
AND (a.grantee = 0 OR pg_get_userbyid(a.grantee) NOT LIKE 'pg\\_%')
|
|
1109
1116
|
AND n.nspname NOT IN (${excluded})
|
|
1110
1117
|
UNION ALL
|
|
1118
|
+
-- Routines, through acldefault(): a NULL proacl is EXECUTE to PUBLIC,
|
|
1119
|
+
-- and leaving routines out restored a SECURITY DEFINER function the
|
|
1120
|
+
-- source kept from the API as callable by anyone.
|
|
1121
|
+
SELECT CASE WHEN a.grantee = 0 THEN 'PUBLIC' ELSE pg_get_userbyid(a.grantee) END,
|
|
1122
|
+
n.nspname, p.proname, NULL::text, a.privilege_type, a.is_grantable,
|
|
1123
|
+
CASE p.prokind WHEN 'p' THEN 'PROCEDURE' ELSE 'FUNCTION' END, pg_get_function_identity_arguments(p.oid)
|
|
1124
|
+
FROM pg_proc p
|
|
1125
|
+
JOIN pg_namespace n ON n.oid = p.pronamespace
|
|
1126
|
+
CROSS JOIN LATERAL aclexplode(coalesce(p.proacl, acldefault('f', p.proowner))) a
|
|
1127
|
+
WHERE a.grantee <> p.proowner
|
|
1128
|
+
AND NOT EXISTS (SELECT 1 FROM pg_depend d WHERE d.classid = 'pg_proc'::regclass AND d.objid = p.oid AND d.deptype = 'e')
|
|
1129
|
+
AND (a.grantee = 0 OR pg_get_userbyid(a.grantee) NOT IN (
|
|
1130
|
+
'postgres','supabase_admin','authenticator','supabase_auth_admin',
|
|
1131
|
+
'supabase_storage_admin','dashboard_user','pgbouncer','supavisor'
|
|
1132
|
+
))
|
|
1133
|
+
AND (a.grantee = 0 OR pg_get_userbyid(a.grantee) NOT LIKE 'pg\\_%')
|
|
1134
|
+
AND n.nspname NOT IN (${excluded})
|
|
1135
|
+
UNION ALL
|
|
1111
1136
|
SELECT CASE WHEN a.grantee = 0 THEN 'PUBLIC' ELSE pg_get_userbyid(a.grantee) END,
|
|
1112
|
-
n.nspname, c.relname, att.attname, a.privilege_type, a.is_grantable
|
|
1137
|
+
n.nspname, c.relname, att.attname, a.privilege_type, a.is_grantable, '', NULL::text
|
|
1113
1138
|
FROM pg_attribute att
|
|
1114
1139
|
JOIN pg_class c ON c.oid = att.attrelid
|
|
1115
1140
|
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
@@ -1117,21 +1142,23 @@ async function captureRoleGrants(dir, dbUrl, queryFn) {
|
|
|
1117
1142
|
WHERE att.attacl IS NOT NULL AND att.attnum > 0 AND NOT att.attisdropped
|
|
1118
1143
|
AND a.grantee <> c.relowner
|
|
1119
1144
|
AND n.nspname NOT IN (${excluded})
|
|
1120
|
-
ORDER BY 1, 2, 3, 4, 5
|
|
1145
|
+
ORDER BY 1, 2, 3, 8, 4, 5
|
|
1121
1146
|
`);
|
|
1122
1147
|
const grouped = /* @__PURE__ */ new Map();
|
|
1123
1148
|
for (const row of rows) {
|
|
1124
1149
|
const key = JSON.stringify([
|
|
1125
1150
|
row.grantee,
|
|
1151
|
+
row.keyword,
|
|
1126
1152
|
row.table_schema,
|
|
1127
1153
|
row.table_name,
|
|
1154
|
+
row.args,
|
|
1128
1155
|
row.column_name,
|
|
1129
1156
|
Boolean(row.is_grantable),
|
|
1130
1157
|
row.privilege_type === "MAINTAIN"
|
|
1131
1158
|
]);
|
|
1132
1159
|
grouped.set(key, [...grouped.get(key) ?? [], row]);
|
|
1133
1160
|
}
|
|
1134
|
-
const statements = [...grouped.values()].map(([row, ...rest]) => `GRANT ${[row, ...rest].map((r) => r.privilege_type + (r.column_name ? ` (${quoteName(r.column_name)})` : "")).join(", ")} ON ${quoteName(row.table_schema)}.${quoteName(row.table_name)} TO ${row.grantee === "PUBLIC" ? "PUBLIC" : quoteName(row.grantee)}` + (row.is_grantable ? " WITH GRANT OPTION" : "") + ";");
|
|
1161
|
+
const statements = [...grouped.values()].map(([row, ...rest]) => `GRANT ${[row, ...rest].map((r) => r.privilege_type + (r.column_name ? ` (${quoteName(r.column_name)})` : "")).join(", ")} ON ${row.keyword ? `${row.keyword} ` : ""}${quoteName(row.table_schema)}.${quoteName(row.table_name)}` + (row.args !== null && row.keyword !== "SEQUENCE" && row.keyword ? `(${row.args})` : "") + ` TO ${row.grantee === "PUBLIC" ? "PUBLIC" : quoteName(row.grantee)}` + (row.is_grantable ? " WITH GRANT OPTION" : "") + ";");
|
|
1135
1162
|
const output = statements.length > 0 ? `-- SupaForge Role Grants Snapshot
|
|
1136
1163
|
-- ${rows.length} grant(s)
|
|
1137
1164
|
|
|
@@ -1251,6 +1278,7 @@ export {
|
|
|
1251
1278
|
dropEquivalentPolicyChanges,
|
|
1252
1279
|
RealtimeCheck,
|
|
1253
1280
|
resolvePgDumpPath,
|
|
1281
|
+
describeMissingPgDump,
|
|
1254
1282
|
getServerMajorVersion,
|
|
1255
1283
|
checkPgDumpCompat,
|
|
1256
1284
|
captureSnapshot,
|
|
@@ -1261,4 +1289,4 @@ export {
|
|
|
1261
1289
|
DEFAULT_KEEP_COUNT,
|
|
1262
1290
|
pruneSnapshots
|
|
1263
1291
|
};
|
|
1264
|
-
//# sourceMappingURL=chunk-
|
|
1292
|
+
//# sourceMappingURL=chunk-MIRLB5JM.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
captureSnapshot,
|
|
7
7
|
findLatestSnapshot,
|
|
8
8
|
loadSnapshot
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MIRLB5JM.js";
|
|
10
10
|
import {
|
|
11
11
|
slugify
|
|
12
12
|
} from "./chunk-DQQ5E563.js";
|
|
@@ -245,4 +245,4 @@ export {
|
|
|
245
245
|
loadMigrations,
|
|
246
246
|
listMigrationFiles
|
|
247
247
|
};
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
248
|
+
//# sourceMappingURL=chunk-NTUASFQ3.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
captureSnapshot,
|
|
3
3
|
checkPgDumpCompat
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MIRLB5JM.js";
|
|
5
5
|
import {
|
|
6
6
|
pgClientConfig,
|
|
7
7
|
pgQuery,
|
|
8
8
|
quoteName
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SQPCWGQO.js";
|
|
10
10
|
import {
|
|
11
11
|
BRANCHES_FILE,
|
|
12
12
|
CLONE_PROGRESS_INTERVAL_MS,
|
|
@@ -639,4 +639,4 @@ export {
|
|
|
639
639
|
isCloneDatabase,
|
|
640
640
|
sourceLooksLikeCloneOf
|
|
641
641
|
};
|
|
642
|
-
//# sourceMappingURL=chunk-
|
|
642
|
+
//# sourceMappingURL=chunk-ORQJVE57.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pgQuery,
|
|
3
3
|
readLocalMigrations
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SQPCWGQO.js";
|
|
5
5
|
import {
|
|
6
6
|
MIGRATIONS_SCHEMA,
|
|
7
7
|
MIGRATIONS_TABLE
|
|
@@ -119,4 +119,4 @@ export {
|
|
|
119
119
|
runMigration,
|
|
120
120
|
baselineMigrations
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-SC2XHGIS.js.map
|