Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -1,3 +1,4 @@
import { loadWebConfig } from "@hivegrid/config";
import { db } from "~/utils/db.server";
// R-P2b — SHK-Standard-Rollen (vom Partner genannt). PROVISORISCH/ANPASSBAR: datengetrieben, per
@@ -78,9 +79,26 @@ export const SHK_ROLE_SEEDS: readonly ShkRoleSeed[] = [
export const SHK_ROLE_NAMES: readonly string[] = SHK_ROLE_SEEDS.map((role) => role.name);
// Product decision 2026-07-07 (Akeshan, resolving the R-P2b seed-vs-design conflict): on PRODUCTION a
// fresh tenant starts with the admin system role only (David's validated D-P2 decision); the 6 SHK seed
// roles stay a staging/dev testing convenience. SEED_SHK_ROLES=true|false overrides either way in case
// the partner wants the seeds in production after all. Environment detection: NODE_ENV is "production"
// on staging containers too, so the deploy-scoped SENTRY_ENVIRONMENT (staging|production, estate
// standard §1) decides first and nodeEnv only covers local dev/test.
export function shouldSeedShkRoles(env: Record<string, string | undefined> = process.env): boolean {
if (env.SEED_SHK_ROLES === "true") return true;
if (env.SEED_SHK_ROLES === "false") return false;
const environment = env.SENTRY_ENVIRONMENT ?? loadWebConfig().config.nodeEnv;
return environment !== "production";
}
// Seedt die SHK-Rollen als App-Rollen eines Tenants (idempotent). Setzt fehlende Rollen + ihre
// vorhandenen Permission-Verknuepfungen auf; bestehende bleiben unberuehrt (anpassbar im Editor).
// Auf Produktion no-op (s. shouldSeedShkRoles) — dort startet ein Tenant nur mit der Admin-Systemrolle.
export async function seedShkRolesForTenant(tenantId: string): Promise<{ createdRoles: number }> {
if (!shouldSeedShkRoles()) {
return { createdRoles: 0 };
}
const wantedKeys = [...new Set(SHK_ROLE_SEEDS.flatMap((role) => role.permissionKeys))];
const permissions = await db.permission.findMany({ where: { name: { in: wantedKeys } }, select: { id: true, name: true } });
const permissionIdByName = new Map(permissions.map((permission) => [permission.name, permission.id]));