@supacloud/cli 0.130.0 → 0.131.0
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
CHANGED
|
@@ -19565,7 +19565,7 @@ var ACTION_POLICY = {
|
|
|
19565
19565
|
init: { local: ["init"] },
|
|
19566
19566
|
env: { local: ["list", "check", "sync"] },
|
|
19567
19567
|
app: {
|
|
19568
|
-
local: ["init", "generate", "infer", "dev", "watch", "verify-plan", "verify", "compile", "check", "graph", "explain", "export-tools", "context", "lens", "doctor", "fix", "plan", "build"],
|
|
19568
|
+
local: ["init", "generate", "infer", "dev", "watch", "verify-plan", "verify", "compile", "check", "graph", "explain", "export-tools", "context", "lens", "doctor", "fix", "upgrade", "client-sdk", "contract-diff", "sql-prepare", "plan", "build"],
|
|
19569
19569
|
read: ["status", "evidence", "logs", "transfer-plan", "promote-plan", "rollback-plan", "history", "deploy-plan", "diff", "promote-status", "preview-plan", "previews", "preview-list", "preview-status"],
|
|
19570
19570
|
write: ["release", "upload", "configure", "transfer", "promote", "promote-reconcile", "deploy", "rollback", "reconcile", "retire", "preview", "preview-create", "preview-reconcile", "preview-cleanup", "preview-pr"]
|
|
19571
19571
|
},
|
|
@@ -30033,6 +30033,7 @@ import { basename as basename8, dirname as dirname9, isAbsolute as isAbsolute6,
|
|
|
30033
30033
|
import { promisify as promisify2 } from "node:util";
|
|
30034
30034
|
import {
|
|
30035
30035
|
applyDiagnosticFix,
|
|
30036
|
+
assessMigration,
|
|
30036
30037
|
buildDeliveryProject,
|
|
30037
30038
|
checkProject,
|
|
30038
30039
|
compileProject,
|
|
@@ -30041,17 +30042,32 @@ import {
|
|
|
30041
30042
|
createExecutionContextPack,
|
|
30042
30043
|
createDiagnosticRepairPlan,
|
|
30043
30044
|
createInferencePlan,
|
|
30045
|
+
diffProjectContracts,
|
|
30044
30046
|
formatInferencePlan,
|
|
30045
30047
|
doctorProject,
|
|
30048
|
+
extractStaticSqlQueriesFromSource,
|
|
30049
|
+
formatContractDiffReport,
|
|
30046
30050
|
formatDoctorCheck,
|
|
30051
|
+
formatMigrationAssessment,
|
|
30052
|
+
generateMultiLangClient,
|
|
30053
|
+
lintArchitectureRules,
|
|
30054
|
+
lintAspectUsage,
|
|
30055
|
+
lintEffectErrorExhaustiveness,
|
|
30056
|
+
lintEnvContract,
|
|
30057
|
+
lintRlsIndexes,
|
|
30058
|
+
lintSqlAgainstCatalog,
|
|
30047
30059
|
loadSupacloudConfig,
|
|
30060
|
+
migrateProject,
|
|
30061
|
+
parseDataCatalogDocument,
|
|
30048
30062
|
formatDeliveryPlan,
|
|
30049
30063
|
planDeliveryProject,
|
|
30064
|
+
readOpenApiJson,
|
|
30050
30065
|
resolveSupacloudConfig,
|
|
30051
30066
|
readExecutionMetadata,
|
|
30052
30067
|
createProjectSemanticSnapshot,
|
|
30053
30068
|
createSemanticLens,
|
|
30054
|
-
watchProject
|
|
30069
|
+
watchProject,
|
|
30070
|
+
verifySqlQueriesAgainstPostgres
|
|
30055
30071
|
} from "@supacloud/compiler";
|
|
30056
30072
|
|
|
30057
30073
|
// src/shared/tools/app-tool-export.ts
|
|
@@ -30177,25 +30193,25 @@ var starter_metadata_default = {
|
|
|
30177
30193
|
generatedBy: "supacloud/starter-metadata-v1",
|
|
30178
30194
|
packages: {
|
|
30179
30195
|
compiler: {
|
|
30180
|
-
version: "0.
|
|
30196
|
+
version: "0.69.0"
|
|
30181
30197
|
},
|
|
30182
30198
|
app: {
|
|
30183
|
-
version: "0.
|
|
30199
|
+
version: "0.41.0",
|
|
30184
30200
|
dependencies: {
|
|
30185
30201
|
rxjs: "7.8.2"
|
|
30186
30202
|
}
|
|
30187
30203
|
},
|
|
30188
30204
|
elysia: {
|
|
30189
|
-
version: "0.
|
|
30205
|
+
version: "0.45.0"
|
|
30190
30206
|
},
|
|
30191
30207
|
commands: {
|
|
30192
|
-
version: "0.
|
|
30208
|
+
version: "0.15.0"
|
|
30193
30209
|
},
|
|
30194
30210
|
contracts: {
|
|
30195
30211
|
version: "0.17.0"
|
|
30196
30212
|
},
|
|
30197
30213
|
db: {
|
|
30198
|
-
version: "0.
|
|
30214
|
+
version: "0.29.0",
|
|
30199
30215
|
dependencies: {},
|
|
30200
30216
|
devDependencies: {},
|
|
30201
30217
|
peerDependencies: {
|
|
@@ -30220,7 +30236,7 @@ var starter_metadata_default = {
|
|
|
30220
30236
|
}
|
|
30221
30237
|
},
|
|
30222
30238
|
sdk: {
|
|
30223
|
-
version: "0.
|
|
30239
|
+
version: "0.50.0",
|
|
30224
30240
|
peerDependencies: {
|
|
30225
30241
|
"@supabase/supabase-js": "^2.118.0"
|
|
30226
30242
|
}
|
|
@@ -36559,6 +36575,58 @@ Scenario: Delivery
|
|
|
36559
36575
|
`
|
|
36560
36576
|
};
|
|
36561
36577
|
}
|
|
36578
|
+
function featureTestingScaffold(name, className, table) {
|
|
36579
|
+
const [schemaName, tableName] = table.includes(".") ? table.split(".", 2) : ["public", table];
|
|
36580
|
+
return {
|
|
36581
|
+
[`${name}.governance.test.ts`]: `import { describe, test } from "bun:test";
|
|
36582
|
+
import { SQL } from "bun";
|
|
36583
|
+
import { assertRlsMatrix, runDurableCommandContractSuite, type SqlExecutor } from "@supacloud/testing";
|
|
36584
|
+
|
|
36585
|
+
const PG_URL = process.env["SUPACLOUD_TEST_PG_URL"];
|
|
36586
|
+
const runIfPg = PG_URL ? test : test.skip;
|
|
36587
|
+
|
|
36588
|
+
function adaptSql(db: SQL): SqlExecutor {
|
|
36589
|
+
return {
|
|
36590
|
+
async query<T = Record<string, unknown>>(statement: string, params?: unknown[]): Promise<T[]> {
|
|
36591
|
+
if (params && params.length > 0) return (await db.unsafe(statement, params)) as unknown as T[];
|
|
36592
|
+
return (await db.unsafe(statement)) as unknown as T[];
|
|
36593
|
+
},
|
|
36594
|
+
};
|
|
36595
|
+
}
|
|
36596
|
+
|
|
36597
|
+
describe("${className} governance contract", () => {
|
|
36598
|
+
runIfPg("enforces multi-role RLS matrix on ${schemaName}.${tableName}", async () => {
|
|
36599
|
+
const db = new SQL(PG_URL!);
|
|
36600
|
+
try {
|
|
36601
|
+
await assertRlsMatrix(adaptSql(db), {
|
|
36602
|
+
roles: [
|
|
36603
|
+
{ label: "anon", role: "anon" },
|
|
36604
|
+
{ label: "authenticated", role: "authenticated", jwtClaims: { sub: "00000000-0000-4000-8000-000000000001" } },
|
|
36605
|
+
],
|
|
36606
|
+
tables: [
|
|
36607
|
+
{
|
|
36608
|
+
schema: ${JSON.stringify(schemaName)},
|
|
36609
|
+
table: ${JSON.stringify(tableName)},
|
|
36610
|
+
probes: {},
|
|
36611
|
+
expectations: {
|
|
36612
|
+
anon: { select: "deny" },
|
|
36613
|
+
authenticated: { select: "empty" },
|
|
36614
|
+
},
|
|
36615
|
+
},
|
|
36616
|
+
],
|
|
36617
|
+
});
|
|
36618
|
+
} finally {
|
|
36619
|
+
await db.close();
|
|
36620
|
+
}
|
|
36621
|
+
});
|
|
36622
|
+
|
|
36623
|
+
test.skip("verifies ${name}.approve idempotency and rollback atomicity (wire runner)", async () => {
|
|
36624
|
+
void runDurableCommandContractSuite;
|
|
36625
|
+
});
|
|
36626
|
+
});
|
|
36627
|
+
`
|
|
36628
|
+
};
|
|
36629
|
+
}
|
|
36562
36630
|
|
|
36563
36631
|
// src/shared/tools/app-local-dev.ts
|
|
36564
36632
|
import { spawn } from "node:child_process";
|
|
@@ -37339,6 +37407,11 @@ async function generateScaffold(args) {
|
|
|
37339
37407
|
}) : resourceScaffold(name, pascalName(name)))) {
|
|
37340
37408
|
writes.push({ path: join15(dir, name, file).replaceAll("\\", "/"), content });
|
|
37341
37409
|
}
|
|
37410
|
+
if (kind === "feature" && args.with_tests) {
|
|
37411
|
+
for (const [file, content] of Object.entries(featureTestingScaffold(name, pascalName(name), featureGovernance.database.table))) {
|
|
37412
|
+
writes.push({ path: join15(dir, name, file).replaceAll("\\", "/"), content });
|
|
37413
|
+
}
|
|
37414
|
+
}
|
|
37342
37415
|
} else {
|
|
37343
37416
|
if (!moduleName?.trim()) {
|
|
37344
37417
|
throw new ScaffoldError("SCAFFOLD_MODULE_REQUIRED", "app generate requires --module; no unique top-level module was inferred");
|
|
@@ -38127,7 +38200,77 @@ async function runCheck(args) {
|
|
|
38127
38200
|
strict: args.strict ?? loadedConfig.strict ?? false
|
|
38128
38201
|
}, root);
|
|
38129
38202
|
const result = await checkProject(config);
|
|
38130
|
-
const
|
|
38203
|
+
const aspectDiagnostics = lintAspectUsage(result.graph);
|
|
38204
|
+
const effectDiagnostics = lintEffectErrorExhaustiveness(result.graph);
|
|
38205
|
+
const collectSourceFiles = async (dirPath) => {
|
|
38206
|
+
const out = [];
|
|
38207
|
+
const skipDirs = new Set(["node_modules", ".git", basename8(config.outDir)]);
|
|
38208
|
+
const walk = async (current) => {
|
|
38209
|
+
const entries = await readdir5(current, { withFileTypes: true }).catch(() => []);
|
|
38210
|
+
for (const entry of entries) {
|
|
38211
|
+
const full = join15(current, entry.name);
|
|
38212
|
+
if (entry.isDirectory()) {
|
|
38213
|
+
if (!skipDirs.has(entry.name))
|
|
38214
|
+
await walk(full);
|
|
38215
|
+
continue;
|
|
38216
|
+
}
|
|
38217
|
+
if (entry.isFile() && /\.(?:ts|mts|svelte)$/.test(entry.name) && !entry.name.endsWith(".d.ts")) {
|
|
38218
|
+
const relToSource = relative8(config.rootDir, full).replaceAll("\\", "/");
|
|
38219
|
+
out.push({
|
|
38220
|
+
file: relToSource,
|
|
38221
|
+
content: await readFile5(full, "utf8")
|
|
38222
|
+
});
|
|
38223
|
+
}
|
|
38224
|
+
}
|
|
38225
|
+
};
|
|
38226
|
+
await walk(config.rootDir);
|
|
38227
|
+
return out;
|
|
38228
|
+
};
|
|
38229
|
+
const sourceFiles = await collectSourceFiles(config.rootDir);
|
|
38230
|
+
const catalogCandidates = [
|
|
38231
|
+
join15(defaults.outDir, "data-catalog.json"),
|
|
38232
|
+
join15(root, "data-catalog.json"),
|
|
38233
|
+
join15(root, "generated", "data-catalog.json")
|
|
38234
|
+
];
|
|
38235
|
+
const catalogPath = catalogCandidates.find((candidate) => existsSync13(candidate));
|
|
38236
|
+
const sqlDiagnostics = [];
|
|
38237
|
+
if (catalogPath) {
|
|
38238
|
+
try {
|
|
38239
|
+
const catalogDoc = parseDataCatalogDocument(JSON.parse(await readFile5(catalogPath, "utf8")));
|
|
38240
|
+
for (const src of sourceFiles) {
|
|
38241
|
+
sqlDiagnostics.push(...lintSqlAgainstCatalog({ sourceText: src.content, file: src.file, catalog: catalogDoc }));
|
|
38242
|
+
}
|
|
38243
|
+
} catch {}
|
|
38244
|
+
}
|
|
38245
|
+
const archDiagnostics = loadedConfig.architectureRules?.length ? lintArchitectureRules({
|
|
38246
|
+
graph: result.graph,
|
|
38247
|
+
rules: loadedConfig.architectureRules,
|
|
38248
|
+
sourceFiles
|
|
38249
|
+
}) : [];
|
|
38250
|
+
const envDiagnostics = loadedConfig.envSchema ? lintEnvContract({
|
|
38251
|
+
envSchema: loadedConfig.envSchema,
|
|
38252
|
+
sourceFiles
|
|
38253
|
+
}) : [];
|
|
38254
|
+
const zmodelCandidates = [
|
|
38255
|
+
join15(root, "zenstack", "schema.zmodel"),
|
|
38256
|
+
join15(root, "prisma", "schema.zmodel"),
|
|
38257
|
+
join15(root, "schema.zmodel")
|
|
38258
|
+
];
|
|
38259
|
+
const zmodelPath = zmodelCandidates.find((candidate) => existsSync13(candidate));
|
|
38260
|
+
const rlsDiagnostics = zmodelPath ? lintRlsIndexes({
|
|
38261
|
+
file: projectRelativePath(root, zmodelPath) ?? "schema.zmodel",
|
|
38262
|
+
zmodelText: await readFile5(zmodelPath, "utf8")
|
|
38263
|
+
}) : [];
|
|
38264
|
+
const combinedDiagnostics = [
|
|
38265
|
+
...result.diagnostics,
|
|
38266
|
+
...aspectDiagnostics,
|
|
38267
|
+
...effectDiagnostics,
|
|
38268
|
+
...sqlDiagnostics,
|
|
38269
|
+
...archDiagnostics,
|
|
38270
|
+
...envDiagnostics,
|
|
38271
|
+
...rlsDiagnostics
|
|
38272
|
+
];
|
|
38273
|
+
const diagnosticError = combinedDiagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
38131
38274
|
const hasError = diagnosticError || result.mismatches.length > 0 || database?.ok === false;
|
|
38132
38275
|
const next = hasError ? diagnosticError || database?.ok === false ? ["supacloud app doctor --format json"] : ["supacloud app compile", "supacloud app check --format json"] : ["supacloud app verify-plan --target <module>"];
|
|
38133
38276
|
if (args.format === "json")
|
|
@@ -38136,7 +38279,7 @@ async function runCheck(args) {
|
|
|
38136
38279
|
ok: !hasError,
|
|
38137
38280
|
next,
|
|
38138
38281
|
source: "declaration",
|
|
38139
|
-
diagnostics:
|
|
38282
|
+
diagnostics: combinedDiagnostics,
|
|
38140
38283
|
mismatches: result.mismatches,
|
|
38141
38284
|
upToDate: result.upToDate,
|
|
38142
38285
|
written: [],
|
|
@@ -38145,7 +38288,7 @@ async function runCheck(args) {
|
|
|
38145
38288
|
}, null, 2), hasError);
|
|
38146
38289
|
const summary = `checked ${result.graph.modules.length} module(s), no files written`;
|
|
38147
38290
|
return textResult2([
|
|
38148
|
-
formatDiagnostics(
|
|
38291
|
+
formatDiagnostics(combinedDiagnostics),
|
|
38149
38292
|
...result.mismatches.map((path) => `generated artifact mismatch: ${path}`),
|
|
38150
38293
|
...database ? [formatDoctorCheck(database)] : [],
|
|
38151
38294
|
"",
|
|
@@ -38153,6 +38296,197 @@ async function runCheck(args) {
|
|
|
38153
38296
|
].join(`
|
|
38154
38297
|
`), hasError);
|
|
38155
38298
|
}
|
|
38299
|
+
async function runUpgrade(args) {
|
|
38300
|
+
const root = resolve20(args.root || process.cwd());
|
|
38301
|
+
const loadedConfig = await loadSupacloudConfig(root);
|
|
38302
|
+
const defaults = resolveSupacloudConfig(loadedConfig, root);
|
|
38303
|
+
const configuredRoot = sourceRoot(args, root, loadedConfig.root);
|
|
38304
|
+
const include = parseInclude(args.include) ?? loadedConfig.include;
|
|
38305
|
+
const compile = compileOptionsFromConfig({
|
|
38306
|
+
...loadedConfig,
|
|
38307
|
+
...configuredRoot === undefined ? {} : { root: configuredRoot },
|
|
38308
|
+
outDir: args.out_dir ? resolve20(root, args.out_dir) : defaults.outDir,
|
|
38309
|
+
...include === undefined ? {} : { include },
|
|
38310
|
+
strict: args.strict ?? loadedConfig.strict ?? false
|
|
38311
|
+
}, root);
|
|
38312
|
+
const assessment = await assessMigration({ projectDir: root, compile });
|
|
38313
|
+
const migrated = await migrateProject({ rootDir: compile.rootDir, include, write: args.write === true });
|
|
38314
|
+
const ok = assessment.ok && migrated.issues.length === 0;
|
|
38315
|
+
const payload = {
|
|
38316
|
+
version: 1,
|
|
38317
|
+
ok,
|
|
38318
|
+
dryRun: args.write !== true,
|
|
38319
|
+
status: assessment.status,
|
|
38320
|
+
findings: assessment.findings,
|
|
38321
|
+
migrations: migrated
|
|
38322
|
+
};
|
|
38323
|
+
if (args.format === "json") {
|
|
38324
|
+
return textResult2(JSON.stringify(payload, null, 2), !ok);
|
|
38325
|
+
}
|
|
38326
|
+
return textResult2([
|
|
38327
|
+
formatMigrationAssessment(assessment),
|
|
38328
|
+
"",
|
|
38329
|
+
`Migration ${args.write === true ? "applied" : "preview"}: ${migrated.files.length} file(s) scanned, ${migrated.changedFiles.length} changed.`
|
|
38330
|
+
].join(`
|
|
38331
|
+
`), !ok);
|
|
38332
|
+
}
|
|
38333
|
+
async function runClientSdk(args) {
|
|
38334
|
+
const root = resolve20(args.root || process.cwd());
|
|
38335
|
+
const language = args.lang;
|
|
38336
|
+
if (language !== "python" && language !== "go" && language !== "dart") {
|
|
38337
|
+
return textResult2("app client-sdk requires --lang python|go|dart", true);
|
|
38338
|
+
}
|
|
38339
|
+
const catalogFile = args.catalog ? resolve20(root, args.catalog) : undefined;
|
|
38340
|
+
const openapiFile = args.openapi ? resolve20(root, args.openapi) : undefined;
|
|
38341
|
+
const catalog = catalogFile && existsSync13(catalogFile) ? parseDataCatalogDocument(JSON.parse(await readFile5(catalogFile, "utf8"))) : undefined;
|
|
38342
|
+
const openapi = openapiFile && existsSync13(openapiFile) ? await readOpenApiJson(openapiFile) : undefined;
|
|
38343
|
+
const generated = generateMultiLangClient({
|
|
38344
|
+
language,
|
|
38345
|
+
catalog,
|
|
38346
|
+
openapi,
|
|
38347
|
+
packageName: args.package_name
|
|
38348
|
+
});
|
|
38349
|
+
if (args.out_dir) {
|
|
38350
|
+
const targetDir = resolve20(root, args.out_dir);
|
|
38351
|
+
await mkdir6(targetDir, { recursive: true });
|
|
38352
|
+
const targetFile = join15(targetDir, generated.filename);
|
|
38353
|
+
await writeFile5(targetFile, generated.content, "utf8");
|
|
38354
|
+
if (args.format === "json") {
|
|
38355
|
+
return textResult2(JSON.stringify({ ok: true, language, file: targetFile, summary: generated.summary }, null, 2));
|
|
38356
|
+
}
|
|
38357
|
+
return textResult2(`Generated ${language} SDK -> ${targetFile}`);
|
|
38358
|
+
}
|
|
38359
|
+
if (args.format === "json") {
|
|
38360
|
+
return textResult2(JSON.stringify({ ok: true, ...generated }, null, 2));
|
|
38361
|
+
}
|
|
38362
|
+
return textResult2(generated.content);
|
|
38363
|
+
}
|
|
38364
|
+
async function runContractDiff(args) {
|
|
38365
|
+
const root = resolve20(args.root || process.cwd());
|
|
38366
|
+
const loadedConfig = await loadSupacloudConfig(root);
|
|
38367
|
+
const defaults = resolveSupacloudConfig(loadedConfig, root);
|
|
38368
|
+
const outDir = args.out_dir ? resolve20(root, args.out_dir) : defaults.outDir;
|
|
38369
|
+
const resolveOptionalJson = async (explicitPath, fallbackPath) => {
|
|
38370
|
+
const candidate = explicitPath ? resolve20(root, explicitPath) : fallbackPath;
|
|
38371
|
+
if (!candidate || !existsSync13(candidate))
|
|
38372
|
+
return;
|
|
38373
|
+
return JSON.parse(await readFile5(candidate, "utf8"));
|
|
38374
|
+
};
|
|
38375
|
+
const resolveOptionalText = async (explicitPath, fallbackPath) => {
|
|
38376
|
+
const candidate = explicitPath ? resolve20(root, explicitPath) : fallbackPath;
|
|
38377
|
+
if (!candidate || !existsSync13(candidate))
|
|
38378
|
+
return;
|
|
38379
|
+
return await readFile5(candidate, "utf8");
|
|
38380
|
+
};
|
|
38381
|
+
const baselineOpenApi = args.baseline_openapi ? await readOpenApiJson(resolve20(root, args.baseline_openapi)) : undefined;
|
|
38382
|
+
const currentOpenApi = baselineOpenApi ? await resolveOptionalJson(args.current_openapi, join15(outDir, "openapi.json")) : undefined;
|
|
38383
|
+
const baselineAsyncApi = await resolveOptionalJson(args.baseline_asyncapi);
|
|
38384
|
+
const currentAsyncApi = baselineAsyncApi ? await resolveOptionalJson(args.current_asyncapi, join15(outDir, "asyncapi.json")) : undefined;
|
|
38385
|
+
const baselineCatalog = await resolveOptionalJson(args.baseline_catalog);
|
|
38386
|
+
const currentCatalog = baselineCatalog ? await resolveOptionalJson(args.current_catalog, join15(outDir, "data-catalog.json")) : undefined;
|
|
38387
|
+
const baselineRls = await resolveOptionalJson(args.baseline_rls);
|
|
38388
|
+
const currentRls = baselineRls ? await resolveOptionalJson(args.current_rls) : undefined;
|
|
38389
|
+
const baselineGraphqlSdl = await resolveOptionalText(args.baseline_graphql);
|
|
38390
|
+
const currentGraphqlSdl = baselineGraphqlSdl ? await resolveOptionalText(args.current_graphql, join15(outDir, "catalog.graphql")) : undefined;
|
|
38391
|
+
if (!baselineOpenApi && !baselineAsyncApi && !baselineCatalog && !baselineRls && !baselineGraphqlSdl) {
|
|
38392
|
+
return textResult2("app contract-diff requires at least one baseline contract (--baseline_openapi, --baseline_asyncapi, --baseline_catalog, --baseline_rls, or --baseline_graphql)", true);
|
|
38393
|
+
}
|
|
38394
|
+
const report = diffProjectContracts({
|
|
38395
|
+
...baselineOpenApi && currentOpenApi ? { baselineOpenApi, currentOpenApi } : {},
|
|
38396
|
+
...baselineAsyncApi && currentAsyncApi ? { baselineAsyncApi, currentAsyncApi } : {},
|
|
38397
|
+
...baselineCatalog && currentCatalog ? { baselineCatalog, currentCatalog } : {},
|
|
38398
|
+
...baselineRls && currentRls ? { baselineRls, currentRls } : {},
|
|
38399
|
+
...baselineGraphqlSdl && currentGraphqlSdl ? { baselineGraphqlSdl, currentGraphqlSdl } : {}
|
|
38400
|
+
});
|
|
38401
|
+
if (args.format === "json") {
|
|
38402
|
+
return textResult2(JSON.stringify(report, null, 2), !report.ok);
|
|
38403
|
+
}
|
|
38404
|
+
return textResult2(formatContractDiffReport(report), !report.ok);
|
|
38405
|
+
}
|
|
38406
|
+
async function collectTsFilesRecursive(dir, rootDir, out) {
|
|
38407
|
+
if (!existsSync13(dir))
|
|
38408
|
+
return;
|
|
38409
|
+
const entries = await readdir5(dir, { withFileTypes: true });
|
|
38410
|
+
for (const entry of entries) {
|
|
38411
|
+
if (entry.name === "node_modules" || entry.name === "generated" || entry.name.startsWith("."))
|
|
38412
|
+
continue;
|
|
38413
|
+
const full = join15(dir, entry.name);
|
|
38414
|
+
if (entry.isDirectory()) {
|
|
38415
|
+
await collectTsFilesRecursive(full, rootDir, out);
|
|
38416
|
+
} else if (entry.isFile() && entry.name.endsWith(".ts") && !entry.name.endsWith(".test.ts")) {
|
|
38417
|
+
out.push({
|
|
38418
|
+
file: relative8(rootDir, full).replaceAll("\\", "/"),
|
|
38419
|
+
content: await readFile5(full, "utf8")
|
|
38420
|
+
});
|
|
38421
|
+
}
|
|
38422
|
+
}
|
|
38423
|
+
}
|
|
38424
|
+
async function runSqlPrepare(args) {
|
|
38425
|
+
const root = resolve20(args.root || process.cwd());
|
|
38426
|
+
const srcFiles = [];
|
|
38427
|
+
await collectTsFilesRecursive(join15(root, "src"), root, srcFiles);
|
|
38428
|
+
const queries = extractStaticSqlQueriesFromSource(srcFiles);
|
|
38429
|
+
const cacheFile = args.cache_path ? resolve20(root, args.cache_path) : join15(root, ".supacloud", "sql-prepare-cache.json");
|
|
38430
|
+
const offline = args.offline === true || !args.database_url;
|
|
38431
|
+
if (offline) {
|
|
38432
|
+
const cache = existsSync13(cacheFile) ? JSON.parse(await readFile5(cacheFile, "utf8")) : undefined;
|
|
38433
|
+
const report = await verifySqlQueriesAgainstPostgres({
|
|
38434
|
+
queries,
|
|
38435
|
+
cache,
|
|
38436
|
+
offline: true,
|
|
38437
|
+
...args.schema_hash ? { schemaHash: args.schema_hash } : {}
|
|
38438
|
+
});
|
|
38439
|
+
if (args.format === "json") {
|
|
38440
|
+
return textResult2(JSON.stringify(report, null, 2), !report.ok);
|
|
38441
|
+
}
|
|
38442
|
+
return textResult2(report.ok ? `SQL prepare offline verification passed (${report.verifiedCount} query/queries).` : report.diagnostics.map((d) => `${d.errorCode ?? d.code}: ${d.message}`).join(`
|
|
38443
|
+
`), !report.ok);
|
|
38444
|
+
}
|
|
38445
|
+
const dbUrl = args.database_url;
|
|
38446
|
+
const pgClient = new Bun.SQL(dbUrl);
|
|
38447
|
+
let seq = 0;
|
|
38448
|
+
const executor = {
|
|
38449
|
+
async prepare(sqlText) {
|
|
38450
|
+
const cleanSql = sqlText.trim().replace(/;+$/, "").trim();
|
|
38451
|
+
if (!cleanSql)
|
|
38452
|
+
return { ok: false, error: "SQL statement must not be empty" };
|
|
38453
|
+
seq += 1;
|
|
38454
|
+
const stmt = `supacloud_cli_prepare_${seq}`;
|
|
38455
|
+
try {
|
|
38456
|
+
await pgClient.unsafe(`PREPARE ${stmt} AS ${cleanSql}`);
|
|
38457
|
+
const meta = await pgClient.unsafe("SELECT parameter_types::text[] AS param_types FROM pg_prepared_statements WHERE name = $1", [stmt]);
|
|
38458
|
+
const firstRow = Array.isArray(meta) ? meta[0] : undefined;
|
|
38459
|
+
const paramTypes = Array.isArray(firstRow?.param_types) ? firstRow.param_types.filter((t) => typeof t === "string") : [];
|
|
38460
|
+
return { ok: true, paramTypes, columns: [] };
|
|
38461
|
+
} catch (err) {
|
|
38462
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
38463
|
+
const code = err && typeof err === "object" && "code" in err && typeof err.code === "string" ? err.code : undefined;
|
|
38464
|
+
return { ok: false, error: msg, ...code ? { code } : {} };
|
|
38465
|
+
} finally {
|
|
38466
|
+
await pgClient.unsafe(`DEALLOCATE ${stmt}`).catch(() => {});
|
|
38467
|
+
}
|
|
38468
|
+
}
|
|
38469
|
+
};
|
|
38470
|
+
try {
|
|
38471
|
+
const report = await verifySqlQueriesAgainstPostgres({
|
|
38472
|
+
queries,
|
|
38473
|
+
executor,
|
|
38474
|
+
...args.schema_hash ? { schemaHash: args.schema_hash } : {}
|
|
38475
|
+
});
|
|
38476
|
+
if (report.ok && args.write === true) {
|
|
38477
|
+
await mkdir6(dirname9(cacheFile), { recursive: true });
|
|
38478
|
+
await writeFile5(cacheFile, `${JSON.stringify(report.cache, null, 2)}
|
|
38479
|
+
`, "utf8");
|
|
38480
|
+
}
|
|
38481
|
+
if (args.format === "json") {
|
|
38482
|
+
return textResult2(JSON.stringify(report, null, 2), !report.ok);
|
|
38483
|
+
}
|
|
38484
|
+
return textResult2(report.ok ? `SQL prepare live verification passed (${report.verifiedCount} query/queries).` : report.diagnostics.map((d) => `${d.errorCode ?? d.code}: ${d.message}`).join(`
|
|
38485
|
+
`), !report.ok);
|
|
38486
|
+
} finally {
|
|
38487
|
+
await pgClient.close();
|
|
38488
|
+
}
|
|
38489
|
+
}
|
|
38156
38490
|
function projectRelativePath(root, path) {
|
|
38157
38491
|
const value = relative8(root, path).replaceAll("\\", "/");
|
|
38158
38492
|
return value === ".." || value.startsWith("../") || value.startsWith("/") ? undefined : value;
|
|
@@ -39069,6 +39403,14 @@ async function runAppTool(request, options = {}) {
|
|
|
39069
39403
|
return runDoctor(request);
|
|
39070
39404
|
case "fix":
|
|
39071
39405
|
return runFix(request);
|
|
39406
|
+
case "upgrade":
|
|
39407
|
+
return runUpgrade(request);
|
|
39408
|
+
case "client-sdk":
|
|
39409
|
+
return runClientSdk(request);
|
|
39410
|
+
case "contract-diff":
|
|
39411
|
+
return runContractDiff(request);
|
|
39412
|
+
case "sql-prepare":
|
|
39413
|
+
return runSqlPrepare(request);
|
|
39072
39414
|
default:
|
|
39073
39415
|
return textResult2(`Unknown app action: ${String(request.action)}`, true);
|
|
39074
39416
|
}
|
|
@@ -39093,6 +39435,10 @@ function registerAppTools(server, options = {}) {
|
|
|
39093
39435
|
"lens",
|
|
39094
39436
|
"doctor",
|
|
39095
39437
|
"fix",
|
|
39438
|
+
"upgrade",
|
|
39439
|
+
"client-sdk",
|
|
39440
|
+
"contract-diff",
|
|
39441
|
+
"sql-prepare",
|
|
39096
39442
|
"plan",
|
|
39097
39443
|
"build",
|
|
39098
39444
|
"release",
|
|
@@ -39156,8 +39502,26 @@ function registerAppTools(server, options = {}) {
|
|
|
39156
39502
|
fix: optional(String2(), "[fix] Path to a DiagnosticFix JSON file produced by `doctor --format json`"),
|
|
39157
39503
|
from_doctor: optional(String2(), "[fix] Read one fix from a doctor --format json output"),
|
|
39158
39504
|
fix_index: optional(Number2({ minimum: 0, multipleOf: 1 }), "[fix] Zero-based fixPlan index used with --from-doctor"),
|
|
39159
|
-
write: optional(Boolean2(), "[fix] Write
|
|
39160
|
-
skip_build: optional(Boolean2(), "[release] Reuse --manifest_path instead of running the local delivery build")
|
|
39505
|
+
write: optional(Boolean2(), "[fix/upgrade/client-sdk] Write changes or generated SDK files to disk (default: preview only)"),
|
|
39506
|
+
skip_build: optional(Boolean2(), "[release] Reuse --manifest_path instead of running the local delivery build"),
|
|
39507
|
+
lang: optional(stringEnum2(["python", "go", "dart"]), "[client-sdk] Target client language"),
|
|
39508
|
+
catalog: optional(String2(), "[client-sdk] Path to data-catalog.json"),
|
|
39509
|
+
openapi: optional(String2(), "[client-sdk] Path to OpenAPI JSON document"),
|
|
39510
|
+
baseline_openapi: optional(String2(), "[contract-diff] Baseline OpenAPI JSON path"),
|
|
39511
|
+
current_openapi: optional(String2(), "[contract-diff] Current OpenAPI JSON path"),
|
|
39512
|
+
baseline_asyncapi: optional(String2(), "[contract-diff] Baseline AsyncAPI JSON path"),
|
|
39513
|
+
current_asyncapi: optional(String2(), "[contract-diff] Current AsyncAPI JSON path"),
|
|
39514
|
+
baseline_catalog: optional(String2(), "[contract-diff] Baseline DataCatalog JSON path"),
|
|
39515
|
+
current_catalog: optional(String2(), "[contract-diff] Current DataCatalog JSON path"),
|
|
39516
|
+
baseline_graphql: optional(String2(), "[contract-diff] Baseline GraphQL SDL path"),
|
|
39517
|
+
current_graphql: optional(String2(), "[contract-diff] Current GraphQL SDL path"),
|
|
39518
|
+
baseline_rls: optional(String2(), "[contract-diff] Baseline RLS snapshot JSON path"),
|
|
39519
|
+
current_rls: optional(String2(), "[contract-diff] Current RLS snapshot JSON path"),
|
|
39520
|
+
cache_path: optional(String2(), "[sql-prepare] SQL prepare cache path (default: .supacloud/sql-prepare-cache.json)"),
|
|
39521
|
+
offline: optional(Boolean2(), "[sql-prepare] Verify SQL against offline cache without connecting to PostgreSQL"),
|
|
39522
|
+
schema_hash: optional(String2(), "[sql-prepare] Expected ZModel schema hash for drift check"),
|
|
39523
|
+
package_name: optional(String2(), "[client-sdk] Package/module name for generated client"),
|
|
39524
|
+
with_tests: optional(Boolean2(), "[generate feature] Also scaffold a @supacloud/testing test file")
|
|
39161
39525
|
}, (request) => runAppTool(request, options));
|
|
39162
39526
|
}
|
|
39163
39527
|
|
|
@@ -44770,7 +45134,7 @@ async function runProjectDeployment(http, args) {
|
|
|
44770
45134
|
// package.json
|
|
44771
45135
|
var package_default = {
|
|
44772
45136
|
name: "@supacloud/cli",
|
|
44773
|
-
version: "0.
|
|
45137
|
+
version: "0.131.0",
|
|
44774
45138
|
description: "Project-scoped CLI for SupaCloud users",
|
|
44775
45139
|
type: "module",
|
|
44776
45140
|
main: "./dist/index.js",
|
|
@@ -44822,23 +45186,23 @@ var package_default = {
|
|
|
44822
45186
|
directory: "packages/cli"
|
|
44823
45187
|
},
|
|
44824
45188
|
dependencies: {
|
|
44825
|
-
"@supacloud/compiler": "^0.
|
|
45189
|
+
"@supacloud/compiler": "^0.69.0",
|
|
44826
45190
|
"@supacloud/delivery": "0.30.1",
|
|
44827
|
-
"@supacloud/db": "0.
|
|
45191
|
+
"@supacloud/db": "0.29.0",
|
|
44828
45192
|
typebox: "1.4.3"
|
|
44829
45193
|
},
|
|
44830
45194
|
overrides: {
|
|
44831
45195
|
"@supacloud/contracts": "0.17.0",
|
|
44832
45196
|
"@supacloud/delivery": "0.30.1",
|
|
44833
45197
|
"@graphql-tools/utils": "^12.0.4",
|
|
44834
|
-
"@supacloud/compiler": "^0.
|
|
44835
|
-
"@supacloud/db": "0.
|
|
45198
|
+
"@supacloud/compiler": "^0.69.0",
|
|
45199
|
+
"@supacloud/db": "0.29.0",
|
|
44836
45200
|
"deepmerge-ts": "8.0.2",
|
|
44837
45201
|
prisma: "6.19.3"
|
|
44838
45202
|
},
|
|
44839
45203
|
devDependencies: {
|
|
44840
45204
|
"@supabase/supabase-js": "2.118.0",
|
|
44841
|
-
"@supacloud/elysia": "0.
|
|
45205
|
+
"@supacloud/elysia": "0.45.0",
|
|
44842
45206
|
"@types/bun": "^1.4.5",
|
|
44843
45207
|
effect: "4.0.5",
|
|
44844
45208
|
elysia: "2.0.0-rc.6",
|
|
@@ -13,3 +13,8 @@ export declare function featureScaffold(name: string, className: string, governa
|
|
|
13
13
|
};
|
|
14
14
|
databaseImportPath?: string;
|
|
15
15
|
}): Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Generates an executable `@supacloud/testing` multi-role RLS matrix & Durable
|
|
18
|
+
* Command contract verification test template alongside a feature slice.
|
|
19
|
+
*/
|
|
20
|
+
export declare function featureTestingScaffold(name: string, className: string, table: string): Record<string, string>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApplicationDeployRequest } from "@supacloud/delivery";
|
|
2
|
+
import { type MultiLangTarget } from "@supacloud/compiler";
|
|
2
3
|
import { type ToolServer } from "../tool-server";
|
|
3
4
|
import { type AppManifest } from "./app-tool-export";
|
|
4
5
|
declare const REMOTE_APP_ACTIONS: {
|
|
@@ -40,7 +41,25 @@ export interface AppToolOptions {
|
|
|
40
41
|
onDevProgress?: (result: ToolResult) => void;
|
|
41
42
|
}
|
|
42
43
|
export interface AppToolArguments {
|
|
43
|
-
action: "init" | "generate" | "infer" | "dev" | "watch" | "verify-plan" | "verify" | "compile" | "check" | "graph" | "explain" | "export-tools" | "context" | "lens" | "doctor" | "fix" | "plan" | "build" | "release" | "promote" | keyof typeof REMOTE_APP_ACTIONS;
|
|
44
|
+
action: "init" | "generate" | "infer" | "dev" | "watch" | "verify-plan" | "verify" | "compile" | "check" | "graph" | "explain" | "export-tools" | "context" | "lens" | "doctor" | "fix" | "upgrade" | "client-sdk" | "contract-diff" | "sql-prepare" | "plan" | "build" | "release" | "promote" | keyof typeof REMOTE_APP_ACTIONS;
|
|
45
|
+
lang?: MultiLangTarget;
|
|
46
|
+
catalog?: string;
|
|
47
|
+
openapi?: string;
|
|
48
|
+
baseline_openapi?: string;
|
|
49
|
+
current_openapi?: string;
|
|
50
|
+
baseline_asyncapi?: string;
|
|
51
|
+
current_asyncapi?: string;
|
|
52
|
+
baseline_catalog?: string;
|
|
53
|
+
current_catalog?: string;
|
|
54
|
+
baseline_graphql?: string;
|
|
55
|
+
current_graphql?: string;
|
|
56
|
+
baseline_rls?: string;
|
|
57
|
+
current_rls?: string;
|
|
58
|
+
cache_path?: string;
|
|
59
|
+
offline?: boolean;
|
|
60
|
+
schema_hash?: string;
|
|
61
|
+
package_name?: string;
|
|
62
|
+
with_tests?: boolean;
|
|
44
63
|
ref?: string;
|
|
45
64
|
id?: string;
|
|
46
65
|
environment_id?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.131.0",
|
|
4
4
|
"description": "Project-scoped CLI for SupaCloud users",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,23 +52,23 @@
|
|
|
52
52
|
"directory": "packages/cli"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@supacloud/compiler": "^0.
|
|
55
|
+
"@supacloud/compiler": "^0.69.0",
|
|
56
56
|
"@supacloud/delivery": "0.30.1",
|
|
57
|
-
"@supacloud/db": "0.
|
|
57
|
+
"@supacloud/db": "0.29.0",
|
|
58
58
|
"typebox": "1.4.3"
|
|
59
59
|
},
|
|
60
60
|
"overrides": {
|
|
61
61
|
"@supacloud/contracts": "0.17.0",
|
|
62
62
|
"@supacloud/delivery": "0.30.1",
|
|
63
63
|
"@graphql-tools/utils": "^12.0.4",
|
|
64
|
-
"@supacloud/compiler": "^0.
|
|
65
|
-
"@supacloud/db": "0.
|
|
64
|
+
"@supacloud/compiler": "^0.69.0",
|
|
65
|
+
"@supacloud/db": "0.29.0",
|
|
66
66
|
"deepmerge-ts": "8.0.2",
|
|
67
67
|
"prisma": "6.19.3"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@supabase/supabase-js": "2.118.0",
|
|
71
|
-
"@supacloud/elysia": "0.
|
|
71
|
+
"@supacloud/elysia": "0.45.0",
|
|
72
72
|
"@types/bun": "^1.4.5",
|
|
73
73
|
"effect": "4.0.5",
|
|
74
74
|
"elysia": "2.0.0-rc.6",
|