migrate to "export default"

also, set no-use-before-define in linter
This commit is contained in:
Girish Ramakrishnan
2026-02-14 15:43:24 +01:00
parent ddb46646fa
commit 36aa641cb9
231 changed files with 2846 additions and 2728 deletions
+120 -119
View File
@@ -1,9 +1,9 @@
import assert from 'node:assert';
import crypto from 'node:crypto';
import * as database from './database.js';
import database from './database.js';
import debugModule from 'debug';
import mysql from 'mysql2';
import * as notifications from './notifications.js';
import notifications from './notifications.js';
import safe from 'safetydance';
const debug = debugModule('box:eventlog');
@@ -13,123 +13,6 @@ const ACTION_USER_LOGIN = 'user.login';
const ACTION_USER_LOGIN_GHOST = 'user.login.ghost';
const ACTION_USER_LOGOUT = 'user.logout';
export default {
add,
upsertLoginEvent,
get,
getActivationEvent,
listPaged,
cleanup,
_clear: clear,
// keep in sync with webadmin index.js filter
ACTION_ACTIVATE,
ACTION_APP_CLONE: 'app.clone',
ACTION_APP_CONFIGURE: 'app.configure',
ACTION_APP_REPAIR: 'app.repair',
ACTION_APP_INSTALL: 'app.install',
ACTION_APP_RESTORE: 'app.restore',
ACTION_APP_IMPORT: 'app.import',
ACTION_APP_UNINSTALL: 'app.uninstall',
ACTION_APP_UPDATE: 'app.update',
ACTION_APP_UPDATE_FINISH: 'app.update.finish',
ACTION_APP_BACKUP: 'app.backup',
ACTION_APP_BACKUP_FINISH: 'app.backup.finish',
ACTION_APP_LOGIN: 'app.login',
ACTION_APP_OOM: 'app.oom',
ACTION_APP_UP: 'app.up',
ACTION_APP_DOWN: 'app.down',
ACTION_APP_START: 'app.start',
ACTION_APP_STOP: 'app.stop',
ACTION_APP_RESTART: 'app.restart',
ACTION_ARCHIVES_ADD: 'archives.add',
ACTION_ARCHIVES_DEL: 'archives.del',
ACTION_BACKUP_FINISH: 'backup.finish',
ACTION_BACKUP_START: 'backup.start',
ACTION_BACKUP_CLEANUP_START: 'backup.cleanup.start', // obsolete
ACTION_BACKUP_CLEANUP_FINISH: 'backup.cleanup.finish',
ACTION_BACKUP_INTEGRITY_START: 'backup.integrity.start',
ACTION_BACKUP_INTEGRITY_FINISH: 'backup.integrity.finish',
ACTION_BACKUP_SITE_ADD: 'backupsite.add',
ACTION_BACKUP_SITE_REMOVE: 'backupsite.remove',
ACTION_BACKUP_SITE_UPDATE: 'backupsite.update',
ACTION_BRANDING_NAME: 'branding.name',
ACTION_BRANDING_FOOTER: 'branding.footer',
ACTION_BRANDING_AVATAR: 'branding.avatar',
ACTION_CERTIFICATE_NEW: 'certificate.new',
ACTION_CERTIFICATE_RENEWAL: 'certificate.renew', // obsolete
ACTION_CERTIFICATE_CLEANUP: 'certificate.cleanup',
ACTION_DASHBOARD_DOMAIN_UPDATE: 'dashboard.domain.update',
ACTION_DIRECTORY_SERVER_CONFIGURE: 'directoryserver.configure',
ACTION_DOMAIN_ADD: 'domain.add',
ACTION_DOMAIN_UPDATE: 'domain.update',
ACTION_DOMAIN_REMOVE: 'domain.remove',
ACTION_EXTERNAL_LDAP_CONFIGURE: 'externalldap.configure',
ACTION_GROUP_ADD: 'group.add',
ACTION_GROUP_REMOVE: 'group.remove',
ACTION_GROUP_UPDATE: 'group.update',
ACTION_GROUP_MEMBERSHIP: 'group.membership',
ACTION_INSTALL_FINISH: 'cloudron.install.finish',
ACTION_MAIL_LOCATION: 'mail.location',
ACTION_MAIL_ENABLED: 'mail.enabled',
ACTION_MAIL_DISABLED: 'mail.disabled',
ACTION_MAIL_MAILBOX_ADD: 'mail.box.add',
ACTION_MAIL_MAILBOX_REMOVE: 'mail.box.remove',
ACTION_MAIL_MAILBOX_UPDATE: 'mail.box.update',
ACTION_MAIL_LIST_ADD: 'mail.list.add',
ACTION_MAIL_LIST_REMOVE: 'mail.list.remove',
ACTION_MAIL_LIST_UPDATE: 'mail.list.update',
ACTION_PROVISION: 'cloudron.provision',
ACTION_RESTORE: 'cloudron.restore', // unused
ACTION_START: 'cloudron.start',
ACTION_REGISTRY_ADD: 'registry.add',
ACTION_REGISTRY_UPDATE: 'registry.update',
ACTION_REGISTRY_DEL: 'registry.del',
ACTION_SERVICE_CONFIGURE: 'service.configure',
ACTION_SERVICE_REBUILD: 'service.rebuild',
ACTION_SERVICE_RESTART: 'service.restart',
ACTION_UPDATE: 'cloudron.update',
ACTION_UPDATE_FINISH: 'cloudron.update.finish',
ACTION_USER_ADD: 'user.add',
ACTION_USER_LOGIN,
ACTION_USER_LOGIN_GHOST,
ACTION_USER_LOGOUT,
ACTION_USER_REMOVE: 'user.remove',
ACTION_USER_UPDATE: 'user.update',
ACTION_USER_TRANSFER: 'user.transfer',
ACTION_USER_DIRECTORY_PROFILE_CONFIG_UPDATE: 'userdirectory.profileconfig.update',
ACTION_VOLUME_ADD: 'volume.add',
ACTION_VOLUME_UPDATE: 'volume.update',
ACTION_VOLUME_REMOUNT: 'volume.remount',
ACTION_VOLUME_REMOVE: 'volume.remove',
ACTION_DYNDNS_UPDATE: 'dyndns.update',
ACTION_SUPPORT_TICKET: 'support.ticket',
ACTION_SUPPORT_SSH: 'support.ssh',
ACTION_PROCESS_CRASH: 'system.crash' // obsolete
};
const EVENTLOG_FIELDS = [ 'id', 'action', 'sourceJson', 'dataJson', 'creationTime' ].join(',');
@@ -255,3 +138,121 @@ async function cleanup(options) {
async function clear() {
await database.query('DELETE FROM eventlog');
}
export default {
add,
upsertLoginEvent,
get,
getActivationEvent,
listPaged,
cleanup,
_clear: clear,
// keep in sync with webadmin index.js filter
ACTION_ACTIVATE,
ACTION_APP_CLONE: 'app.clone',
ACTION_APP_CONFIGURE: 'app.configure',
ACTION_APP_REPAIR: 'app.repair',
ACTION_APP_INSTALL: 'app.install',
ACTION_APP_RESTORE: 'app.restore',
ACTION_APP_IMPORT: 'app.import',
ACTION_APP_UNINSTALL: 'app.uninstall',
ACTION_APP_UPDATE: 'app.update',
ACTION_APP_UPDATE_FINISH: 'app.update.finish',
ACTION_APP_BACKUP: 'app.backup',
ACTION_APP_BACKUP_FINISH: 'app.backup.finish',
ACTION_APP_LOGIN: 'app.login',
ACTION_APP_OOM: 'app.oom',
ACTION_APP_UP: 'app.up',
ACTION_APP_DOWN: 'app.down',
ACTION_APP_START: 'app.start',
ACTION_APP_STOP: 'app.stop',
ACTION_APP_RESTART: 'app.restart',
ACTION_ARCHIVES_ADD: 'archives.add',
ACTION_ARCHIVES_DEL: 'archives.del',
ACTION_BACKUP_FINISH: 'backup.finish',
ACTION_BACKUP_START: 'backup.start',
ACTION_BACKUP_CLEANUP_START: 'backup.cleanup.start', // obsolete
ACTION_BACKUP_CLEANUP_FINISH: 'backup.cleanup.finish',
ACTION_BACKUP_INTEGRITY_START: 'backup.integrity.start',
ACTION_BACKUP_INTEGRITY_FINISH: 'backup.integrity.finish',
ACTION_BACKUP_SITE_ADD: 'backupsite.add',
ACTION_BACKUP_SITE_REMOVE: 'backupsite.remove',
ACTION_BACKUP_SITE_UPDATE: 'backupsite.update',
ACTION_BRANDING_NAME: 'branding.name',
ACTION_BRANDING_FOOTER: 'branding.footer',
ACTION_BRANDING_AVATAR: 'branding.avatar',
ACTION_CERTIFICATE_NEW: 'certificate.new',
ACTION_CERTIFICATE_RENEWAL: 'certificate.renew', // obsolete
ACTION_CERTIFICATE_CLEANUP: 'certificate.cleanup',
ACTION_DASHBOARD_DOMAIN_UPDATE: 'dashboard.domain.update',
ACTION_DIRECTORY_SERVER_CONFIGURE: 'directoryserver.configure',
ACTION_DOMAIN_ADD: 'domain.add',
ACTION_DOMAIN_UPDATE: 'domain.update',
ACTION_DOMAIN_REMOVE: 'domain.remove',
ACTION_EXTERNAL_LDAP_CONFIGURE: 'externalldap.configure',
ACTION_GROUP_ADD: 'group.add',
ACTION_GROUP_REMOVE: 'group.remove',
ACTION_GROUP_UPDATE: 'group.update',
ACTION_GROUP_MEMBERSHIP: 'group.membership',
ACTION_INSTALL_FINISH: 'cloudron.install.finish',
ACTION_MAIL_LOCATION: 'mail.location',
ACTION_MAIL_ENABLED: 'mail.enabled',
ACTION_MAIL_DISABLED: 'mail.disabled',
ACTION_MAIL_MAILBOX_ADD: 'mail.box.add',
ACTION_MAIL_MAILBOX_REMOVE: 'mail.box.remove',
ACTION_MAIL_MAILBOX_UPDATE: 'mail.box.update',
ACTION_MAIL_LIST_ADD: 'mail.list.add',
ACTION_MAIL_LIST_REMOVE: 'mail.list.remove',
ACTION_MAIL_LIST_UPDATE: 'mail.list.update',
ACTION_PROVISION: 'cloudron.provision',
ACTION_RESTORE: 'cloudron.restore', // unused
ACTION_START: 'cloudron.start',
ACTION_REGISTRY_ADD: 'registry.add',
ACTION_REGISTRY_UPDATE: 'registry.update',
ACTION_REGISTRY_DEL: 'registry.del',
ACTION_SERVICE_CONFIGURE: 'service.configure',
ACTION_SERVICE_REBUILD: 'service.rebuild',
ACTION_SERVICE_RESTART: 'service.restart',
ACTION_UPDATE: 'cloudron.update',
ACTION_UPDATE_FINISH: 'cloudron.update.finish',
ACTION_USER_ADD: 'user.add',
ACTION_USER_LOGIN,
ACTION_USER_LOGIN_GHOST,
ACTION_USER_LOGOUT,
ACTION_USER_REMOVE: 'user.remove',
ACTION_USER_UPDATE: 'user.update',
ACTION_USER_TRANSFER: 'user.transfer',
ACTION_USER_DIRECTORY_PROFILE_CONFIG_UPDATE: 'userdirectory.profileconfig.update',
ACTION_VOLUME_ADD: 'volume.add',
ACTION_VOLUME_UPDATE: 'volume.update',
ACTION_VOLUME_REMOUNT: 'volume.remount',
ACTION_VOLUME_REMOVE: 'volume.remove',
ACTION_DYNDNS_UPDATE: 'dyndns.update',
ACTION_SUPPORT_TICKET: 'support.ticket',
ACTION_SUPPORT_SSH: 'support.ssh',
ACTION_PROCESS_CRASH: 'system.crash' // obsolete
};