database admin yay

This commit is contained in:
legop3
2026-06-28 20:17:58 -04:00
parent 5fca14bef5
commit 78fc891cb9
16 changed files with 851 additions and 21 deletions
+46
View File
@@ -0,0 +1,46 @@
// Identity Database API
// Purpose: Keeps /database socket event names and acknowledgement handling local to the database admin feature.
// Scope: Provides small promise helpers over the shared socket without adding app-wide SessionContext actions.
export function emitIdentityAdmin(socket, eventName, payload = {}) {
return new Promise((resolve, reject) => {
socket.emit(eventName, payload, (resp = {}) => {
if (resp.error) {
reject(new Error(resp.error));
return;
}
resolve(resp);
});
});
}
export function listUsers(socket) {
return emitIdentityAdmin(socket, 'identityAdmin:listUsers');
}
export function getUser(socket, userId) {
return emitIdentityAdmin(socket, 'identityAdmin:getUser', { userId });
}
export function addSignal(socket, userId, type, value) {
return emitIdentityAdmin(socket, 'identityAdmin:addSignal', { userId, type, value });
}
export function removeSignal(socket, userId, type, value) {
return emitIdentityAdmin(socket, 'identityAdmin:removeSignal', { userId, type, value });
}
export function setVerified(socket, userId, enabled) {
return emitIdentityAdmin(socket, 'identityAdmin:setVerified', { userId, enabled });
}
export function setDeterrence(socket, userId, enabled, reason) {
return emitIdentityAdmin(socket, 'identityAdmin:setDeterrence', { userId, enabled, reason });
}
export function updateFeatureState(socket, userId, namespace, value) {
return emitIdentityAdmin(socket, 'identityAdmin:updateFeatureState', { userId, namespace, value });
}
export function deleteFeatureState(socket, userId, namespace) {
return emitIdentityAdmin(socket, 'identityAdmin:deleteFeatureState', { userId, namespace });
}