@supacloud/cli 0.43.0 → 0.44.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.
- package/dist/index.js +26 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -238773,7 +238773,7 @@ var ACTION_POLICY = {
|
|
|
238773
238773
|
database: {
|
|
238774
238774
|
read: ["list_tables", "describe_columns", "list_indexes", "list_constraints", "list_extensions", "rls_status", "rls_policies", "list_auth_users", "get_auth_user", "connections", "stats", "slow_queries", "list_migrations", "migration_inventory", "project_url", "generate_types", "database_lint", "db_lint", "rpc_catalog", "list_rpcs"],
|
|
238775
238775
|
local: ["lint_migrations", "lint"],
|
|
238776
|
-
write: ["query", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls"]
|
|
238776
|
+
write: ["query", "execute", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls"]
|
|
238777
238777
|
},
|
|
238778
238778
|
supabase: {
|
|
238779
238779
|
local: ["version", "migration_new", "db_diff", "db_reset", "db_pull", "db_dump", "migration_list", "gen_types"],
|
|
@@ -240466,15 +240466,17 @@ function registerDatabaseTools(server2, http, config = {}) {
|
|
|
240466
240466
|
"rpc_catalog",
|
|
240467
240467
|
"list_rpcs"
|
|
240468
240468
|
];
|
|
240469
|
-
const writeActions = ["apply_migration", "push_migrations", "baseline_migrations", "create_table_rls"];
|
|
240469
|
+
const writeActions = ["execute", "apply_migration", "push_migrations", "baseline_migrations", "create_table_rls"];
|
|
240470
240470
|
const remoteActions = [...readActions, ...localActions];
|
|
240471
240471
|
const allActions = localOnly ? localActions : readOnly ? remoteActions : [...remoteActions, ...writeActions];
|
|
240472
240472
|
server2.tool("database", `Database operations: query, schema, RLS, migrations, stats.
|
|
240473
240473
|
Actions: ${allActions.join(", ")}${localOnly ? " (local-only mode)" : readOnly ? " (read-only mode)" : ""}`, {
|
|
240474
240474
|
action: withDescription(stringEnum(allActions), "Action"),
|
|
240475
240475
|
ref: projectRef ? Type.Optional(Type.String()) : optional(Type.String(), "Project ref"),
|
|
240476
|
-
sql: optional(Type.String(), "[query/apply_migration/lint_migrations/lint] SQL statement"),
|
|
240477
|
-
file: optional(Type.String(), "[query/apply_migration/lint_migrations/lint] Read SQL from local file path (avoids shell escaping issues with $$ and multi-statement DDL)"),
|
|
240476
|
+
sql: optional(Type.String(), "[query/execute/apply_migration/lint_migrations/lint] SQL statement"),
|
|
240477
|
+
file: optional(Type.String(), "[query/execute/apply_migration/lint_migrations/lint] Read SQL from local file path (avoids shell escaping issues with $$ and multi-statement DDL)"),
|
|
240478
|
+
mode: optional(stringEnum(["read", "migration", "admin"]), "[query/execute] SQL execution mode: read, migration, or admin. execute defaults to migration; query defaults to read/auto"),
|
|
240479
|
+
admin: optional(Type.Boolean(), "[query/execute] Admin execution flag (required when mode=admin)"),
|
|
240478
240480
|
dir: optional(Type.String(), "[push_migrations/baseline_migrations/lint_migrations/lint] Directory containing .sql migration files (default: supabase/migrations)"),
|
|
240479
240481
|
dry_run: optional(Type.Boolean(), "[push_migrations/baseline_migrations] Preview changes without applying them"),
|
|
240480
240482
|
strict: optional(Type.Boolean(), "[push_migrations/lint_migrations/lint/database_lint] Exit with error if high-risk issues or migrations are detected"),
|
|
@@ -240510,12 +240512,16 @@ Actions: ${allActions.join(", ")}${localOnly ? " (local-only mode)" : readOnly ?
|
|
|
240510
240512
|
return { content: [{ type: "text", text: `❌ Failed to read file ${args.file}: ${e.message}` }] };
|
|
240511
240513
|
}
|
|
240512
240514
|
}
|
|
240513
|
-
const execSql = async (sql, mode) => managementHttp().post(`/v1/projects/${ref}/database/sql`,
|
|
240515
|
+
const execSql = async (sql, mode, admin) => managementHttp().post(`/v1/projects/${ref}/database/sql`, {
|
|
240516
|
+
sql,
|
|
240517
|
+
...mode ? { mode } : {},
|
|
240518
|
+
...admin !== undefined ? { admin } : {}
|
|
240519
|
+
});
|
|
240514
240520
|
let text;
|
|
240515
240521
|
switch (action) {
|
|
240516
240522
|
case "query": {
|
|
240517
240523
|
if (!args.sql)
|
|
240518
|
-
throw new Error("'sql' required");
|
|
240524
|
+
throw new Error("'sql' or 'file' required");
|
|
240519
240525
|
if (readOnly) {
|
|
240520
240526
|
const upper = args.sql.trim().toUpperCase();
|
|
240521
240527
|
for (const kw of ["INSERT", "UPDATE", "DELETE", "DROP", "CREATE", "ALTER", "TRUNCATE"]) {
|
|
@@ -240523,7 +240529,18 @@ Actions: ${allActions.join(", ")}${localOnly ? " (local-only mode)" : readOnly ?
|
|
|
240523
240529
|
return { content: [{ type: "text", text: `❌ Write blocked: ${kw} (read-only mode)` }] };
|
|
240524
240530
|
}
|
|
240525
240531
|
}
|
|
240526
|
-
const r = await execSql(args.sql);
|
|
240532
|
+
const r = await execSql(args.sql, args.mode, args.admin);
|
|
240533
|
+
text = r.ok ? formatSqlResult(r.data) : `❌ Failed (${r.status}): ${JSON.stringify(r.data)}`;
|
|
240534
|
+
break;
|
|
240535
|
+
}
|
|
240536
|
+
case "execute": {
|
|
240537
|
+
if (readOnly) {
|
|
240538
|
+
return { content: [{ type: "text", text: "❌ Write blocked: execute (read-only mode)" }] };
|
|
240539
|
+
}
|
|
240540
|
+
if (!args.sql)
|
|
240541
|
+
throw new Error("'sql' or 'file' required");
|
|
240542
|
+
const mode = args.mode || "migration";
|
|
240543
|
+
const r = await execSql(args.sql, mode, args.admin);
|
|
240527
240544
|
text = r.ok ? formatSqlResult(r.data) : `❌ Failed (${r.status}): ${JSON.stringify(r.data)}`;
|
|
240528
240545
|
break;
|
|
240529
240546
|
}
|
|
@@ -247828,7 +247845,7 @@ function commandScaffold(moduleName, name) {
|
|
|
247828
247845
|
@Injectable()
|
|
247829
247846
|
@Command({
|
|
247830
247847
|
name: ${JSON.stringify(`${moduleName}.${camelName2(name)}`)},
|
|
247831
|
-
// TODO:
|
|
247848
|
+
// TODO: Declare business permission identifier (e.g. ${moduleName}.${camelName2(name)})
|
|
247832
247849
|
permission: "TODO",
|
|
247833
247850
|
})
|
|
247834
247851
|
export class ${pascalName2(name)}Command {}
|
|
@@ -251226,7 +251243,7 @@ function registerRemoteDevTools(server2, options = {}) {
|
|
|
251226
251243
|
// package.json
|
|
251227
251244
|
var package_default = {
|
|
251228
251245
|
name: "@supacloud/cli",
|
|
251229
|
-
version: "0.
|
|
251246
|
+
version: "0.44.1",
|
|
251230
251247
|
description: "Project-scoped CLI for SupaCloud users",
|
|
251231
251248
|
type: "module",
|
|
251232
251249
|
main: "./dist/index.js",
|