ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: Tasker workspace adapter в Launcher
This commit is contained in:
@@ -103,6 +103,7 @@ export function createControlPlaneStore({ projectRoot }) {
|
||||
demoEndsAt: nullableString(payload?.demoEndsAt),
|
||||
contactName: nullableString(payload?.contactName),
|
||||
contactEmail: nullableString(payload?.contactEmail),
|
||||
integrations: normalizeClientIntegrations(payload?.integrations),
|
||||
notes: nullableString(payload?.notes),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
@@ -138,6 +139,9 @@ export function createControlPlaneStore({ projectRoot }) {
|
||||
client.demoEndsAt = nullableStringWithFallback(payload?.demoEndsAt, client.demoEndsAt ?? null);
|
||||
client.contactName = nullableStringWithFallback(payload?.contactName, client.contactName ?? null);
|
||||
client.contactEmail = nullableStringWithFallback(payload?.contactEmail, client.contactEmail ?? null);
|
||||
if ("integrations" in (payload ?? {})) {
|
||||
client.integrations = normalizeClientIntegrations(payload.integrations, client.integrations);
|
||||
}
|
||||
client.notes = nullableStringWithFallback(payload?.notes, client.notes ?? null);
|
||||
client.updatedAt = isoNow();
|
||||
|
||||
@@ -154,6 +158,28 @@ export function createControlPlaneStore({ projectRoot }) {
|
||||
return { client, data };
|
||||
}
|
||||
|
||||
async function recordTaskManagerWorkspaceMembership(payload, identity) {
|
||||
const data = readData();
|
||||
const actor = resolveActor(data, identity);
|
||||
const client = findById(data.clients, payload?.clientId, "client");
|
||||
const user = findById(data.users, payload?.userId, "user");
|
||||
const taskManager = typeof payload?.taskManager === "object" && payload.taskManager !== null ? payload.taskManager : {};
|
||||
const membership = typeof taskManager.membership === "object" && taskManager.membership !== null ? taskManager.membership : {};
|
||||
const workspace = typeof membership.workspace === "object" && membership.workspace !== null ? membership.workspace : {};
|
||||
|
||||
addAuditEvent(data, actor, {
|
||||
action: "Назначен Tasker workspace",
|
||||
objectType: "task-manager-membership",
|
||||
objectName: user.name,
|
||||
clientId: client.id,
|
||||
result: "success",
|
||||
details: `Workspace: ${workspace.name ?? workspace.slug ?? payload?.workspaceSlug}; Role: ${membership.role ?? payload?.role ?? "member"}`,
|
||||
});
|
||||
|
||||
await writeData(data);
|
||||
return { data };
|
||||
}
|
||||
|
||||
async function deleteClient(clientId, identity) {
|
||||
const data = readData();
|
||||
const actor = resolveActor(data, identity);
|
||||
@@ -1028,6 +1054,7 @@ export function createControlPlaneStore({ projectRoot }) {
|
||||
reorderServices,
|
||||
retrySync,
|
||||
markUserAuthentikProvisioned,
|
||||
recordTaskManagerWorkspaceMembership,
|
||||
setUserServiceAccess,
|
||||
updateClient,
|
||||
updateGroup,
|
||||
@@ -1052,6 +1079,10 @@ function normalizeData(payload) {
|
||||
}
|
||||
|
||||
data.settings = normalizeSettings(data.settings);
|
||||
data.clients = data.clients.map((client) => ({
|
||||
...client,
|
||||
integrations: normalizeClientIntegrations(client.integrations),
|
||||
}));
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1074,6 +1105,21 @@ function normalizeSettings(payload) {
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeClientIntegrations(payload, fallback = {}) {
|
||||
const integrations = typeof payload === "object" && payload !== null ? payload : {};
|
||||
const fallbackIntegrations = typeof fallback === "object" && fallback !== null ? fallback : {};
|
||||
const taskManager = typeof integrations.taskManager === "object" && integrations.taskManager !== null ? integrations.taskManager : {};
|
||||
const fallbackTaskManager =
|
||||
typeof fallbackIntegrations.taskManager === "object" && fallbackIntegrations.taskManager !== null ? fallbackIntegrations.taskManager : {};
|
||||
|
||||
return {
|
||||
taskManager: {
|
||||
workspaceSlug: nullableStringWithFallback(taskManager.workspaceSlug, fallbackTaskManager.workspaceSlug ?? null),
|
||||
workspaceName: nullableStringWithFallback(taskManager.workspaceName, fallbackTaskManager.workspaceName ?? null),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function resolveActor(data, identity) {
|
||||
const user = data.users.find(
|
||||
(item) =>
|
||||
|
||||
Reference in New Issue
Block a user