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
+49
@@ -0,0 +1,49 @@
|
||||
// Demo data is a staging/dev-only affordance. Staging deploys set
|
||||
// SEED_DEMO_DATA=true + ALLOW_STAGING_DEMO_SEED=true (see .gitea/workflows/
|
||||
// deploy.yml); production resources must never set those flags (enforced by
|
||||
// scripts/verify-gitea-deploy-workflow.mjs). When the demo UI is disabled the
|
||||
// list loaders ignore the `demo=show` query param server-side and the list
|
||||
// screens hide their "show demo data" checkbox entirely.
|
||||
//
|
||||
// Mirrors the guard pair used by SeedService.shouldSeedCrmDemoData and
|
||||
// AuthService.isStagingDemoLoginAllowed: outside production the demo UI is
|
||||
// always available (local dev provisions demo data via the settings page);
|
||||
// in production it requires both staging flags.
|
||||
|
||||
import { loadWebConfig } from "@hivegrid/config";
|
||||
|
||||
type DemoDataUiEnvironment = {
|
||||
NODE_ENV?: string;
|
||||
SEED_DEMO_DATA?: string;
|
||||
ALLOW_STAGING_DEMO_SEED?: string;
|
||||
SEED_DEMO_PRO_MANAGED?: string;
|
||||
SEED_DEMO_PRO_EXPECTED_TENANT_ID?: string;
|
||||
};
|
||||
|
||||
type DemoDataTenantContext = {
|
||||
tenantId?: string | null;
|
||||
tenantSlug?: string | null;
|
||||
};
|
||||
|
||||
const MANAGED_NORMAL_DATA_TENANT_SLUG = "demo-pro-crm";
|
||||
|
||||
export function isManagedNormalDataTenant(context: DemoDataTenantContext, env?: DemoDataUiEnvironment): boolean {
|
||||
const demoEnv = env ?? (process.env as DemoDataUiEnvironment);
|
||||
if (demoEnv.SEED_DEMO_PRO_MANAGED !== "true") return false;
|
||||
const expectedTenantId = demoEnv.SEED_DEMO_PRO_EXPECTED_TENANT_ID?.trim();
|
||||
if (expectedTenantId && context.tenantId === expectedTenantId) return true;
|
||||
return context.tenantSlug === MANAGED_NORMAL_DATA_TENANT_SLUG;
|
||||
}
|
||||
|
||||
export function isDemoDataUiEnabled(env?: DemoDataUiEnvironment, context?: DemoDataTenantContext): boolean {
|
||||
const demoEnv = env ?? (process.env as DemoDataUiEnvironment);
|
||||
if (context && isManagedNormalDataTenant(context, demoEnv)) return false;
|
||||
// Injected env keeps tests hermetic; the runtime default resolves NODE_ENV
|
||||
// through @hivegrid/config (runtime NODE_ENV boundary, enforced by
|
||||
// apps/web/app/utils/runtime-node-env-boundary.test.ts).
|
||||
const nodeEnv = env ? env.NODE_ENV : loadWebConfig().config.nodeEnv;
|
||||
if (nodeEnv !== "production") {
|
||||
return true;
|
||||
}
|
||||
return demoEnv.SEED_DEMO_DATA === "true" && demoEnv.ALLOW_STAGING_DEMO_SEED === "true";
|
||||
}
|
||||
Reference in new issue
Block a user