Add BIM viewer service launch integration
This commit is contained in:
@@ -62,6 +62,48 @@ const publicPoolClient = {
|
||||
createdAt: "2026-05-09T00:00:00.000Z",
|
||||
updatedAt: "2026-05-09T00:00:00.000Z",
|
||||
};
|
||||
const bimViewerService = {
|
||||
id: "service_bim_viewer",
|
||||
slug: "bim-viewer",
|
||||
title: "BIM VIEWER",
|
||||
subtitle: "BIM и CAD просмотр",
|
||||
description: "Персональный просмотр BIM/CAD моделей, версий и публичных ссылок.",
|
||||
fullDescription:
|
||||
"Standalone BIM/CAD viewer NODE.DC для рабочих моделей, вложений Operational Core, персонального модельного хранилища и безопасного внешнего просмотра по share-ссылкам.",
|
||||
url: "https://bim.nodedc.ru",
|
||||
launchUrl: "https://bim.nodedc.ru",
|
||||
accentColor: "#8FE3C8",
|
||||
fallbackGradient: "linear-gradient(132deg, rgba(143, 227, 200, 0.78), rgba(24, 70, 64, 0.9) 46%, #080B0F 84%)",
|
||||
status: "active",
|
||||
order: 25,
|
||||
authentikApplicationSlug: "bim-viewer",
|
||||
authentikGroupName: "nodedc:bim:access",
|
||||
isAvailableForAllNewClients: true,
|
||||
createdAt: "2026-06-18T00:00:00.000Z",
|
||||
updatedAt: "2026-06-18T00:00:00.000Z",
|
||||
};
|
||||
const bimViewerDefaultGrants = [
|
||||
{
|
||||
id: "grant_bim_viewer_client_romashka",
|
||||
serviceId: "service_bim_viewer",
|
||||
targetType: "client",
|
||||
targetId: "client_romashka",
|
||||
appRole: "member",
|
||||
status: "active",
|
||||
createdAt: "2026-06-18T00:00:00.000Z",
|
||||
updatedAt: "2026-06-18T00:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "grant_bim_viewer_client_public_pool",
|
||||
serviceId: "service_bim_viewer",
|
||||
targetType: "client",
|
||||
targetId: publicPoolClientId,
|
||||
appRole: "member",
|
||||
status: "active",
|
||||
createdAt: "2026-06-18T00:00:00.000Z",
|
||||
updatedAt: "2026-06-18T00:00:00.000Z",
|
||||
},
|
||||
];
|
||||
const defaultSettings = {
|
||||
brand: {
|
||||
logoLinkUrl: "/",
|
||||
@@ -2281,9 +2323,89 @@ function normalizeData(payload) {
|
||||
data.taskerInviteRequests = data.taskerInviteRequests.map(normalizeTaskerInviteRequest).filter(Boolean);
|
||||
data.engineWorkflowAccessRequests = data.engineWorkflowAccessRequests.map(normalizeEngineWorkflowAccessRequest).filter(Boolean);
|
||||
applyProtectedLauncherUserInvariants(data);
|
||||
applyBimViewerServiceInvariants(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
function applyBimViewerServiceInvariants(data) {
|
||||
let service = data.services.find(
|
||||
(candidate) => candidate.id === bimViewerService.id || candidate.slug === bimViewerService.slug
|
||||
);
|
||||
|
||||
if (!service) {
|
||||
service = normalizeService({ ...bimViewerService });
|
||||
data.services.push(service);
|
||||
} else {
|
||||
service.id = service.id || bimViewerService.id;
|
||||
service.slug = service.slug || bimViewerService.slug;
|
||||
service.title = service.title || bimViewerService.title;
|
||||
service.subtitle = service.subtitle || bimViewerService.subtitle;
|
||||
service.description = service.description || bimViewerService.description;
|
||||
service.fullDescription = service.fullDescription || bimViewerService.fullDescription;
|
||||
service.url = service.url || bimViewerService.url;
|
||||
service.launchUrl = service.launchUrl || service.url || bimViewerService.launchUrl;
|
||||
service.accentColor = service.accentColor || bimViewerService.accentColor;
|
||||
service.fallbackGradient = service.fallbackGradient || bimViewerService.fallbackGradient;
|
||||
service.status = service.status || bimViewerService.status;
|
||||
service.order = service.order ?? bimViewerService.order;
|
||||
service.authentikApplicationSlug = service.authentikApplicationSlug || bimViewerService.authentikApplicationSlug;
|
||||
service.authentikGroupName = service.authentikGroupName || bimViewerService.authentikGroupName;
|
||||
service.isAvailableForAllNewClients = service.isAvailableForAllNewClients ?? true;
|
||||
service.createdAt = service.createdAt || bimViewerService.createdAt;
|
||||
service.updatedAt = service.updatedAt || bimViewerService.updatedAt;
|
||||
}
|
||||
|
||||
const serviceId = service.id || bimViewerService.id;
|
||||
for (const defaultGrant of bimViewerDefaultGrants) {
|
||||
const grant = { ...defaultGrant, serviceId };
|
||||
const exists = data.grants.some(
|
||||
(candidate) =>
|
||||
candidate.serviceId === grant.serviceId &&
|
||||
candidate.targetType === grant.targetType &&
|
||||
candidate.targetId === grant.targetId
|
||||
);
|
||||
if (!exists) {
|
||||
data.grants.push({ ...grant });
|
||||
}
|
||||
}
|
||||
|
||||
ensureStaticSyncStatus(data, {
|
||||
id: "sync_bim_viewer_authentik",
|
||||
objectId: serviceId,
|
||||
objectName: bimViewerService.title,
|
||||
objectType: "service",
|
||||
});
|
||||
for (const defaultGrant of bimViewerDefaultGrants) {
|
||||
const grant = { ...defaultGrant, serviceId };
|
||||
ensureStaticSyncStatus(data, {
|
||||
id: `sync_${grant.id}`,
|
||||
objectId: grant.id,
|
||||
objectName: `${bimViewerService.slug}:${grant.targetType}:${grant.targetId}`,
|
||||
objectType: "grant",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function ensureStaticSyncStatus(data, status) {
|
||||
const exists = data.syncStatuses.some(
|
||||
(candidate) => candidate.target === "authentik" && candidate.objectType === status.objectType && candidate.objectId === status.objectId
|
||||
);
|
||||
if (exists) {
|
||||
return;
|
||||
}
|
||||
data.syncStatuses.push({
|
||||
id: status.id,
|
||||
objectId: status.objectId,
|
||||
objectName: status.objectName,
|
||||
objectType: status.objectType,
|
||||
target: "authentik",
|
||||
state: "pending",
|
||||
lastSyncAt: null,
|
||||
error: null,
|
||||
updatedAt: "2026-06-18T00:00:00.000Z",
|
||||
});
|
||||
}
|
||||
|
||||
function applyProtectedLauncherUserInvariants(data) {
|
||||
const rootUser = data.users.find((user) => isProtectedLauncherUserId(user.id));
|
||||
if (!rootUser) return;
|
||||
|
||||
Reference in New Issue
Block a user