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

@@ -6,15 +6,12 @@ import { getPaginationFromCurrentUrl } from "~/utils/helpers/RowPaginationHelper
import PeriodHelper from "~/utils/helpers/PeriodHelper";
import { promiseHash } from "~/utils/promises/promiseHash";
import { getAdminDashboardStats } from "~/utils/services/adminDashboardService";
import { getSetupSteps } from "~/utils/services/setupService";
import type { SetupItem } from "~/application/dtos/setup/SetupItem";
import type { Stat } from "~/application/dtos/stats/Stat";
import type { PaginationDto } from "~/application/dtos/data/PaginationDto";
export type AdminDashboardLoaderData = {
title: string;
stats: Stat[];
setupSteps: SetupItem[];
tenants: {
items: TenantWithUsage[];
pagination: PaginationDto;
@@ -29,13 +26,12 @@ export async function loadAdminDashboardRouteData({ request, params }: AdminDash
const currentPagination = getPaginationFromCurrentUrl(urlSearchParams);
const { t } = await time(getTranslations(request), "getTranslations");
const { stats, setupSteps, tenants } = await time(
const { stats, tenants } = await time(
promiseHash({
stats: time(
getAdminDashboardStats({ t, gte: PeriodHelper.getGreaterThanOrEqualsFromRequest({ request }) }),
"admin.dashboard.details.getAdminDashboardStats"
),
setupSteps: time(getSetupSteps(), "admin.dashboard.details.getSetupSteps"),
tenants: time(adminGetAllTenantsWithUsage(undefined, currentPagination), "admin.dashboard.details.adminGetAllTenantsWithUsage"),
}),
"admin.dashboard.details"
@@ -44,7 +40,6 @@ export async function loadAdminDashboardRouteData({ request, params }: AdminDash
const data: AdminDashboardLoaderData = {
title: `${t("app.sidebar.dashboard")} | ${process.env.APP_NAME}`,
stats,
setupSteps,
tenants,
};
return { data, headers: getServerTimingHeader() };
@@ -3,12 +3,10 @@ import { DefaultPermission } from "~/application/dtos/shared/DefaultPermissions"
import { TimeFunction } from "~/modules/metrics/services/.server/MetricTracker";
import OnboardingService from "~/modules/onboarding/services/OnboardingService";
import UrlUtils from "~/utils/app/UrlUtils";
import { getAllEntities } from "~/utils/db/entities/entities.db.server";
import { getAllEntityGroups } from "~/utils/db/entities/entityGroups.db.server";
import { getMyGroups } from "~/utils/db/permissions/groups.db.server";
import { getAllRolesWithoutPermissions } from "~/utils/db/permissions/roles.db.server";
import { getPermissionsByUser, getUserRoleInAdmin } from "~/utils/db/permissions/userRoles.db.server";
import { getTenantsForUser as getMyTenants } from "@toolctrl/db/auth-boundary.server";
import { getTenantsForUser as getMyTenants } from "@hivegrid/db/auth-boundary.server";
import { getAllTenantTypes } from "~/utils/db/tenants/tenantTypes.db.server";
import { getUserTotpStatus } from "~/utils/db/users.db.server";
import { enforceAdminMfa } from "~/utils/auth/mfa/enforcement.server";
@@ -16,7 +14,7 @@ import { checkMfaStepUpState } from "~/utils/auth/mfa/step-up.server";
import { promiseHash } from "~/utils/promises/promiseHash";
import { getUserInfo, getUserSession } from "~/utils/session.server";
import { AdminLoaderData } from "../useAdminData";
import { getAuthUserWithoutPasswordById as getUser } from "@toolctrl/db/auth-boundary.server";
import { getAuthUserWithoutPasswordById as getUser } from "@hivegrid/db/auth-boundary.server";
import { TFunction } from "i18next";
import { redirect } from "react-router";
import { NOT_FOUND_ENVELOPE } from "~/utils/errors.server";
@@ -55,12 +53,10 @@ export async function loadAdminData({ request, t }: { request: Request; t: TFunc
const myTenants = await time(getMyTenants(user.id), "getMyTenants");
const { allPermissions, superAdminRole, entities, entityGroups, allRoles, myGroups, onboardingSession } = await time(
const { allPermissions, superAdminRole, allRoles, myGroups, onboardingSession } = await time(
promiseHash({
allPermissions: getPermissionsByUser(userInfo.userId, null),
superAdminRole: getUserRoleInAdmin(userInfo.userId, DefaultAdminRoles.SuperAdmin),
entities: getAllEntities({ tenantId: null }),
entityGroups: getAllEntityGroups(),
allRoles: getAllRolesWithoutPermissions("admin"),
myGroups: getMyGroups(user.id, null),
onboardingSession: OnboardingService.getUserActiveOnboarding({ userId: user.id, tenantId: null, request }),
@@ -71,8 +67,6 @@ export async function loadAdminData({ request, t }: { request: Request; t: TFunc
user,
myTenants,
currentTenant: null,
entities,
entityGroups,
// roles,
allRoles,
permissions: allPermissions.map((f) => f as DefaultPermission),
@@ -27,7 +27,7 @@ const mocks = vi.hoisted(() => {
vi.mock("~/utils/services/.server/urlService", () => ({ getTenantIdFromUrl: vi.fn(async () => "tenant_1") }));
vi.mock("~/utils/session.server", () => ({ getUserInfo: vi.fn(async () => ({ userId: "user_1", lng: "en" })) }));
vi.mock("@toolctrl/db/auth-boundary.server", () => ({
vi.mock("@hivegrid/db/auth-boundary.server", () => ({
getAuthUserWithoutPasswordById: vi.fn(async () => ({ id: "user_1", admin: false, locale: "en" })),
getTenantsForUser: vi.fn(async () => [{ id: "tenant_1", slug: "acme", name: "Acme" }]),
}));
@@ -36,9 +36,7 @@ vi.mock("~/utils/db/tenants.db.server", () => ({
getTenantSimple: vi.fn(async () => ({ id: "tenant_1", slug: "acme", name: "Acme", deactivatedReason: null })),
getTenantUserType: vi.fn(() => mocks.postDetails.tenantUser.promise),
}));
vi.mock("@toolctrl/config", () => ({ loadRequiredWebConfig: vi.fn(() => ({ routing: {} })) }));
vi.mock("~/utils/db/entities/entities.db.server", () => ({ getAllEntities: vi.fn(async () => []) }));
vi.mock("~/utils/db/entities/entityGroups.db.server", () => ({ getAllEntityGroups: vi.fn(async () => []) }));
vi.mock("@hivegrid/config", () => ({ loadRequiredWebConfig: vi.fn(() => ({ routing: {} })) }));
vi.mock("~/utils/db/permissions/groups.db.server", () => ({ getMyGroups: vi.fn(async () => []) }));
vi.mock("~/utils/db/permissions/roles.db.server", () => ({ getAllRolesWithoutPermissions: vi.fn(async () => []) }));
vi.mock("~/utils/db/permissions/userRoles.db.server", () => ({
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest";
vi.mock("~/utils/services/.server/urlService", () => ({ getTenantIdFromUrl: vi.fn(async () => "tenant_1") }));
vi.mock("~/utils/session.server", () => ({ getUserInfo: vi.fn(async () => ({ userId: "user_1", lng: "en" })) }));
vi.mock("@toolctrl/db/auth-boundary.server", () => ({
vi.mock("@hivegrid/db/auth-boundary.server", () => ({
getAuthUserWithoutPasswordById: vi.fn(async () => ({ id: "user_1", admin: false, locale: "en" })),
getTenantsForUser: vi.fn(),
}));
@@ -10,9 +10,7 @@ vi.mock("~/utils/db/tenants.db.server", () => ({
getTenantSimple: vi.fn(async () => ({ id: "tenant_1", slug: "acme", name: "Acme", deactivatedReason: null })),
getTenantUserType: vi.fn(),
}));
vi.mock("@toolctrl/config", () => ({ loadRequiredWebConfig: vi.fn(() => ({ routing: {} })) }));
vi.mock("~/utils/db/entities/entities.db.server", () => ({ getAllEntities: vi.fn() }));
vi.mock("~/utils/db/entities/entityGroups.db.server", () => ({ getAllEntityGroups: vi.fn() }));
vi.mock("@hivegrid/config", () => ({ loadRequiredWebConfig: vi.fn(() => ({ routing: {} })) }));
vi.mock("~/utils/db/permissions/groups.db.server", () => ({ getMyGroups: vi.fn() }));
vi.mock("~/utils/db/permissions/roles.db.server", () => ({ getAllRolesWithoutPermissions: vi.fn() }));
vi.mock("~/utils/db/permissions/userRoles.db.server", () => ({
@@ -1,7 +1,6 @@
import { Params, redirect } from "react-router";
import { DefaultAdminRoles } from "~/application/dtos/shared/DefaultAdminRoles";
import { DefaultAppRoles } from "~/application/dtos/shared/DefaultAppRoles";
import { DefaultEntityTypes } from "~/application/dtos/shared/DefaultEntityTypes";
import { DefaultPermission } from "~/application/dtos/shared/DefaultPermissions";
import { TenantUserType } from "~/application/enums/tenants/TenantUserType";
import { timeFake, TimeFunction } from "~/modules/metrics/services/.server/MetricTracker";
@@ -9,14 +8,12 @@ import OnboardingService from "~/modules/onboarding/services/OnboardingService";
import { absoluteAppRootPath } from "~/utils/app/CrossHostUrls";
import { appPath } from "~/utils/app/CanonicalUrlUtils";
import UrlUtils from "~/utils/app/UrlUtils";
import { loadRequiredWebConfig } from "@toolctrl/config";
import { getAllEntities } from "~/utils/db/entities/entities.db.server";
import { getAllEntityGroups } from "~/utils/db/entities/entityGroups.db.server";
import { loadRequiredWebConfig } from "@hivegrid/config";
import { getMyGroups } from "~/utils/db/permissions/groups.db.server";
import { getAllRolesWithoutPermissions } from "~/utils/db/permissions/roles.db.server";
import { getPermissionsByUser, getUserRoleInTenant, getUserRoleInAdmin } from "~/utils/db/permissions/userRoles.db.server";
import { adminGetAllActiveTenantSimple, getTenantSimple, getTenantUserType } from "~/utils/db/tenants.db.server";
import { getAuthUserWithoutPasswordById as getUser, getTenantsForUser as getMyTenants } from "@toolctrl/db/auth-boundary.server";
import { getAuthUserWithoutPasswordById as getUser, getTenantsForUser as getMyTenants } from "@hivegrid/db/auth-boundary.server";
import { getAllTenantTypes } from "~/utils/db/tenants/tenantTypes.db.server";
import { promiseHash } from "~/utils/promises/promiseHash";
import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
@@ -27,13 +24,31 @@ import { PlanFeatureUsageDto } from "~/application/dtos/subscriptions/PlanFeatur
import { CreditTypes } from "~/modules/usage/dtos/CreditType";
import { DefaultFeatures } from "~/application/dtos/shared/DefaultFeatures";
import { TFunction } from "i18next";
import { featureKeys, type FeatureKey } from "@toolctrl/entitlements";
import { featureKeys, type FeatureKey } from "@hivegrid/entitlements";
import { resolveTenantProductAccess } from "~/utils/entitlements/.server/productAccess.server";
import { WALKING_SKELETON_MODULE_KEY } from "~/modules/walkingSkeleton/constants";
// Every feature key the AppSidebar gates on via hasFeatureAccess() MUST be
// listed here — a key missing from this list resolves to no productAccess entry
// and silently hides the sidebar item for ALL tenants/plans (recurring footgun:
// files+tasks were re-added in 1017cf58b; dashboard/automation/leads/projects/
// hr/integrations/email-inbox/booking/forms re-added 2026-07-07 after the R-P5
// verification found "Integrationen" unreachable despite being plan-included).
const tenantNavigationFeatureKeys = [
featureKeys.dashboard,
featureKeys.crmBasic,
featureKeys.leads,
featureKeys.projects,
featureKeys.files,
featureKeys.tasks,
featureKeys.hr,
featureKeys.integrations,
featureKeys.booking,
featureKeys.forms,
featureKeys.search,
featureKeys.automation,
featureKeys.emailMarketing,
featureKeys.emailInbox,
featureKeys.api,
featureKeys.workflowEngine,
featureKeys.credits,
@@ -51,6 +66,7 @@ export async function loadAppData({
tenantId: preloadedTenantId,
userInfo: preloadedUserInfo,
user: preloadedUser,
isOperatorAdmin: preloadedIsOperatorAdmin,
}: {
request: Request;
params: Params;
@@ -59,6 +75,7 @@ export async function loadAppData({
tenantId?: string;
userInfo?: Awaited<ReturnType<typeof getUserInfo>>;
user?: Awaited<ReturnType<typeof getUser>>;
isOperatorAdmin?: boolean;
}) {
const { tenantId, userInfo } = await time(
promiseHash({
@@ -94,18 +111,14 @@ export async function loadAppData({
if (UrlUtils.stripTrailingSlash(url.pathname) === UrlUtils.stripTrailingSlash(appPath({ tenantSlug: tenantPathSegment, mode: "host-aware" }))) {
throw redirect(`${appPath({ tenantSlug: currentTenant.slug, path: "dashboard", mode: "host-aware" })}${url.search}`);
}
let { myTenants, mySubscription, allPermissions, superUserRole, superAdminRole, entities, entityGroups, allRoles, myGroups, onboardingSession } = await time(
const operatorAdmin = Boolean(user.admin) || Boolean(preloadedIsOperatorAdmin);
let { myTenants, mySubscription, allPermissions, superUserRole, superAdminRole, allRoles, myGroups, onboardingSession } = await time(
promiseHash({
myTenants: time(user.admin ? adminGetAllActiveTenantSimple() : getMyTenants(user.id), "loadAppData.getDetails.getMyTenants"),
myTenants: time(operatorAdmin ? adminGetAllActiveTenantSimple() : getMyTenants(user.id), "loadAppData.getDetails.getMyTenants"),
mySubscription: time(getActiveTenantSubscriptions(tenantId), "loadAppData.getDetails.getActiveTenantSubscriptions"),
allPermissions: time(getPermissionsByUser(userInfo.userId, tenantId), "loadAppData.getDetails.getPermissionsByUser"),
superUserRole: time(getUserRoleInTenant(userInfo.userId, tenantId, DefaultAppRoles.SuperUser), "loadAppData.getDetails.getUserRoleInTenant"),
superAdminRole: time(getUserRoleInAdmin(userInfo.userId, DefaultAdminRoles.SuperAdmin), "loadAppData.getDetails.getUserRoleInAdmin"),
entities: time(
getAllEntities({ tenantId, active: true, types: [DefaultEntityTypes.All, DefaultEntityTypes.AppOnly] }),
"loadAppData.getDetails.getAllEntities"
),
entityGroups: time(getAllEntityGroups(), "loadAppData.getDetails.getAllEntityGroups()"),
allRoles: time(getAllRolesWithoutPermissions("app"), "loadAppData.getDetails.getAllRolesWithoutPermissions"),
myGroups: time(getMyGroups(user.id, currentTenant.id), "loadAppData.getDetails.getMyGroups"),
onboardingSession: time(
@@ -134,7 +147,7 @@ export async function loadAppData({
featureKey,
subscription: mySubscription,
tenantRolePermissionNames: allPermissions,
bypassTenantRolePermission: !!user.admin || !!superAdminRole,
bypassTenantRolePermission: operatorAdmin || !!superAdminRole,
}),
] as const)
),
@@ -143,7 +156,7 @@ export async function loadAppData({
}),
"loadAppData.postDetails"
);
const currentRole = user.admin ? TenantUserType.ADMIN : tenantUser?.type ?? TenantUserType.MEMBER;
const currentRole = operatorAdmin ? TenantUserType.ADMIN : tenantUser?.type ?? TenantUserType.MEMBER;
const data: AppLoaderData = {
// i18n: i18n.translations,
user,
@@ -151,8 +164,6 @@ export async function loadAppData({
currentTenant,
currentRole,
mySubscription,
entities,
entityGroups,
// roles,
allRoles,
permissions: allPermissions.map((f) => f as DefaultPermission),
@@ -26,10 +26,10 @@ function readLoader(relativePath: string) {
}
describe("auth boundary imports for shared data loaders", () => {
it.each(dataLoaderPaths)("imports migrated auth/user/tenant reads from @toolctrl/db in $path", ({ path: relativePath }) => {
it.each(dataLoaderPaths)("imports migrated auth/user/tenant reads from @hivegrid/db in $path", ({ path: relativePath }) => {
const source = readLoader(relativePath);
expect(source).toContain("@toolctrl/db/auth-boundary.server");
expect(source).toContain("@hivegrid/db/auth-boundary.server");
});
it.each(dataLoaderPaths)("does not import migrated app DB wrappers in $path", ({ path: relativePath, blockedImports }) => {
@@ -43,10 +43,10 @@ describe("auth boundary imports for shared data loaders", () => {
});
describe("auth boundary imports for tenant selection routes", () => {
it.each(tenantSelectionRoutePaths)("imports migrated auth/user/tenant reads from @toolctrl/db in %s", (relativePath) => {
it.each(tenantSelectionRoutePaths)("imports migrated auth/user/tenant reads from @hivegrid/db in %s", (relativePath) => {
const source = readLoader(relativePath);
expect(source).toContain("@toolctrl/db/auth-boundary.server");
expect(source).toContain("@hivegrid/db/auth-boundary.server");
});
it.each(tenantSelectionRoutePaths)("does not import migrated app DB wrappers in %s", (relativePath) => {
@@ -1,10 +1,11 @@
import { loadRequiredWebConfig } from "@toolctrl/config";
import { getAuthUserWithoutPasswordById as getUser, getTenantById as getTenant, getTenantByIdOrSlug } from "@toolctrl/db/auth-boundary.server";
import { loadRequiredWebConfig } from "@hivegrid/config";
import { getAuthUserWithoutPasswordById as getUser, getTenantById as getTenant, getTenantByIdOrSlug } from "@hivegrid/db/auth-boundary.server";
import { Params } from "react-router";
import { AnalyticsInfoDto } from "~/application/dtos/marketing/AnalyticsInfoDto";
import { ImpersonatingSessionDto } from "~/application/dtos/session/ImpersonatingSessionDto";
import { CookieCategory } from "~/application/cookies/CookieCategory";
import { remixI18Next, i18nCookie } from "~/locale/i18next.server";
import { resolveAnrede } from "~/locale/anrede.server";
import { getCurrentEnabledFlagNames } from "~/utils/services/.server/featureFlagsRequest.server";
import { createMetrics } from "~/modules/metrics/services/.server/MetricTracker";
import { getAnalyticsSession, generateAnalyticsUserId, commitAnalyticsSession, destroyAnalyticsSession } from "~/utils/analyticsCookie.server";
@@ -71,12 +72,18 @@ export async function loadRootData({ request, params }: { request: Request; para
}
const locale = await remixI18Next.getLocale(request);
// Formality axis (du/Sie). Default "du" → `effectiveLng(locale, "du") === locale`,
// so the language handed to `useChangeLanguage` in root.tsx is unchanged and
// rendering stays byte-identical. The tenant's persisted default applies when
// no explicit cookie/param is present.
const anrede = await resolveAnrede(request, currentTenant);
const webConfig = loadRequiredWebConfig();
const data: AppRootData = {
metatags: [{ title: webConfig.appName }],
user,
currentTenant,
locale,
anrede,
theme: userInfo.theme || appConfiguration.app.theme,
serverUrl: getBaseURL(request),
publicBaseUrl: getAbsoluteUrl(request, "/"),
@@ -86,7 +93,6 @@ export async function loadRootData({ request, params }: { request: Request; para
userSession: userInfo,
authenticated: userInfo.userId?.length > 0,
debug: webConfig.nodeEnv === "development",
isStripeTest: webConfig.stripe.secretKey?.startsWith("sk_test_") ?? true,
chatWebsiteId: webConfig.crisp.chatWebsiteId,
appConfiguration,
csrf,