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
+28
@@ -0,0 +1,28 @@
|
||||
import { featureKeys } from "@hivegrid/entitlements";
|
||||
import { CatalogError, foundationErrors } from "@hivegrid/foundation";
|
||||
import { loadRequiredWebConfig } from "@hivegrid/config";
|
||||
|
||||
import { tenantHasModule } from "~/utils/connector/tenantConnector.server";
|
||||
import type { IntegrationsRouteContext } from "~/utils/integrations/integrationsAccess.server";
|
||||
|
||||
export const KWP_INTEGRATION_MODULE_KEY = featureKeys.kwpIntegration;
|
||||
|
||||
export async function hasKwpIntegrationModule(context: IntegrationsRouteContext): Promise<boolean> {
|
||||
const configuredTenantId = loadRequiredWebConfig().kwp?.hiveGridTenantId?.trim();
|
||||
if (!configuredTenantId || configuredTenantId !== context.tenantId) return false;
|
||||
return tenantHasModule({
|
||||
tenantId: context.tenantId,
|
||||
userId: context.userId,
|
||||
moduleKey: KWP_INTEGRATION_MODULE_KEY,
|
||||
});
|
||||
}
|
||||
|
||||
/** Fail closed with the platform's 404 permission semantics. */
|
||||
export async function requireKwpIntegrationModule(
|
||||
context: IntegrationsRouteContext,
|
||||
): Promise<IntegrationsRouteContext> {
|
||||
if (!(await hasKwpIntegrationModule(context))) {
|
||||
throw new CatalogError(foundationErrors.notFound, { module: KWP_INTEGRATION_MODULE_KEY });
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in new issue
Block a user