Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+50
@@ -0,0 +1,50 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
import { disconnectDbClients, getWriteDbClient } from "@hivegrid/db/client.server";
|
||||
import { verifyPortalRlsRuntimeReadiness } from "@hivegrid/db/portal-rls-runtime-readiness.server";
|
||||
|
||||
import { verifyPortalAppWorkerPolicyParity } from "./lib/portal-app-worker-policy-parity.js";
|
||||
|
||||
const TENANT_POLICY_ARTIFACT = new URL("../prisma/rls/tenant-policy-contract-isolation.sql", import.meta.url);
|
||||
|
||||
export async function verifyPortalMigrationChainPolicyState() {
|
||||
const client = getWriteDbClient();
|
||||
const readiness = await verifyPortalRlsRuntimeReadiness([client], {
|
||||
...process.env,
|
||||
RLS_RUNTIME_MODE: "required",
|
||||
});
|
||||
|
||||
if (readiness.mode !== "required" || !readiness.ready) {
|
||||
const diagnostics = readiness.diagnostics.length ? readiness.diagnostics.join(", ") : "portal policy readiness did not run in required mode";
|
||||
throw new Error(`Portal migration-chain policy parity failed: ${diagnostics}`);
|
||||
}
|
||||
|
||||
const canonicalTenantPolicySql = await readFile(TENANT_POLICY_ARTIFACT, "utf8");
|
||||
await verifyPortalAppWorkerPolicyParity(client, canonicalTenantPolicySql);
|
||||
|
||||
return readiness;
|
||||
}
|
||||
|
||||
function isDirectExecution() {
|
||||
return Boolean(process.argv[1]) && import.meta.url === pathToFileURL(process.argv[1]).href;
|
||||
}
|
||||
|
||||
if (isDirectExecution()) {
|
||||
try {
|
||||
await verifyPortalMigrationChainPolicyState();
|
||||
process.stdout.write("PASS migration-chain portal policy parity\n");
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "unknown portal policy parity failure";
|
||||
process.stderr.write(`FAIL ${message}\n`);
|
||||
process.exitCode = 1;
|
||||
} finally {
|
||||
try {
|
||||
await disconnectDbClients();
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "unknown database disconnect failure";
|
||||
process.stderr.write(`FAIL ${message}\n`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user