diff --git a/packages/app/src/__deprecated__/main/main.ts b/packages/app/src/__deprecated__/main/main.ts index 4968cfbfd6..034910d35c 100644 --- a/packages/app/src/__deprecated__/main/main.ts +++ b/packages/app/src/__deprecated__/main/main.ts @@ -24,11 +24,7 @@ import registerCopyFileListener from "App/__deprecated__/main/functions/register import registerWriteGzipListener from "App/__deprecated__/main/functions/register-write-gzip-listener" import registerRmdirListener from "App/__deprecated__/main/functions/register-rmdir-listener" import registerArchiveFilesListener from "App/__deprecated__/main/functions/register-archive-files-listener" -import registerReadFileListener from "App/file-system/listeners/read-file.listener" import createDownloadListenerRegistrar from "App/__deprecated__/main/functions/create-download-listener-registrar" -import registerEncryptFileListener from "App/file-system/listeners/encrypt-file.listener" -import registerDecryptFileListener from "App/file-system/listeners/decrypt-file.listener" -import registerUnlinkFileListener from "App/file-system/listeners/unlink-file.listener" import { registerDownloadHelpHandler, removeDownloadHelpHandler, @@ -196,10 +192,6 @@ const createWindow = async () => { registerRmdirListener() registerWriteGzipListener() registerArchiveFilesListener() - registerEncryptFileListener() - registerReadFileListener() - registerUnlinkFileListener() - registerDecryptFileListener() registerMetadataAllGetValueListener() registerMetadataGetValueListener() registerMetadataSetValueListener() diff --git a/packages/app/src/analytic-data-tracker/constants/controller.constant.ts b/packages/app/src/analytic-data-tracker/constants/controller.constant.ts index 1efb0ea5f4..c1205a8d77 100644 --- a/packages/app/src/analytic-data-tracker/constants/controller.constant.ts +++ b/packages/app/src/analytic-data-tracker/constants/controller.constant.ts @@ -3,24 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "analytic-data-tracker" - export enum IpcAnalyticDataTrackerEvent { - Track = "track", - TrackUnique = "track-unique", - TrackWithoutDeviceCheck = "track-without-device-check", - TrackUniqueWithoutDeviceCheck = "track-unique-without-device-check", - ToggleTracking = "toggle-tracking", - SetExternalUsageDevice = "set-external-usage-device", - SetVisitorMetadata = "set-visitor-metadata", -} - -export enum IpcAnalyticDataTrackerRequest { - Track = "analytic-data-tracker-track", - TrackUnique = "analytic-data-tracker-track-unique", - TrackWithoutDeviceCheck = "analytic-data-tracker-track-without-device-check", - TrackUniqueWithoutDeviceCheck = "analytic-data-tracker-track-unique-without-device-check", - ToggleTracking = "analytic-data-tracker-toggle-tracking", - SetExternalUsageDevice = "analytic-data-tracker-set-external-usage-device", - SetVisitorMetadata = "analytic-data-tracker-set-visitor-metadata", + Track = "analytic_track", + TrackUnique = "analytic_track-unique", + TrackWithoutDeviceCheck = "analytic_track-without-device-check", + TrackUniqueWithoutDeviceCheck = "analytic_track-unique-without-device-check", + ToggleTracking = "analytic_toggle-tracking", + SetExternalUsageDevice = "analytic_set-external-usage-device", + SetVisitorMetadata = "analytic_set-visitor-metadata", } diff --git a/packages/app/src/analytic-data-tracker/controllers/analytic-data-tracker.controller.ts b/packages/app/src/analytic-data-tracker/controllers/analytic-data-tracker.controller.ts index 20ad83e23c..bbe0538b89 100644 --- a/packages/app/src/analytic-data-tracker/controllers/analytic-data-tracker.controller.ts +++ b/packages/app/src/analytic-data-tracker/controllers/analytic-data-tracker.controller.ts @@ -3,18 +3,14 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" -import { - ControllerPrefix, - IpcAnalyticDataTrackerEvent, -} from "App/analytic-data-tracker/constants" +import { IpcEvent } from "App/core/decorators" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" import { AnalyticDataTrackerClass, VisitorMetadata, } from "App/analytic-data-tracker/services" import { TrackEvent } from "App/analytic-data-tracker/types" -@Controller(ControllerPrefix) export class AnalyticDataTrackerController { constructor(private tracker: AnalyticDataTrackerClass) {} diff --git a/packages/app/src/analytic-data-tracker/requests/set-external-usage-device.request.ts b/packages/app/src/analytic-data-tracker/requests/set-external-usage-device.request.ts index 03bcd5717c..0859c8394e 100644 --- a/packages/app/src/analytic-data-tracker/requests/set-external-usage-device.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/set-external-usage-device.request.ts @@ -4,13 +4,13 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" export const setExternalUsageDeviceRequest = async ( flag: boolean ): Promise => { return ipcRenderer.callMain( - IpcAnalyticDataTrackerRequest.SetExternalUsageDevice, + IpcAnalyticDataTrackerEvent.SetExternalUsageDevice, flag ) } diff --git a/packages/app/src/analytic-data-tracker/requests/set-visitor-metadata.request.ts b/packages/app/src/analytic-data-tracker/requests/set-visitor-metadata.request.ts index 30f4f3145c..1dfe99e739 100644 --- a/packages/app/src/analytic-data-tracker/requests/set-visitor-metadata.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/set-visitor-metadata.request.ts @@ -4,14 +4,14 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" import { VisitorMetadata } from "App/analytic-data-tracker/services" export const setVisitorMetadataRequest = async ( visitorMetadata: VisitorMetadata ): Promise => { return ipcRenderer.callMain( - IpcAnalyticDataTrackerRequest.SetVisitorMetadata, + IpcAnalyticDataTrackerEvent.SetVisitorMetadata, visitorMetadata ) } diff --git a/packages/app/src/analytic-data-tracker/requests/toggle-tracking.request.ts b/packages/app/src/analytic-data-tracker/requests/toggle-tracking.request.ts index b91fe7f5f7..8248fc9535 100644 --- a/packages/app/src/analytic-data-tracker/requests/toggle-tracking.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/toggle-tracking.request.ts @@ -4,8 +4,8 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" export const toggleTrackingRequest = async (flag: boolean): Promise => { - return ipcRenderer.callMain(IpcAnalyticDataTrackerRequest.ToggleTracking, flag) + return ipcRenderer.callMain(IpcAnalyticDataTrackerEvent.ToggleTracking, flag) } diff --git a/packages/app/src/analytic-data-tracker/requests/track-unique-without-device-check.request.ts b/packages/app/src/analytic-data-tracker/requests/track-unique-without-device-check.request.ts index 92cfe70d6c..273e3fd32a 100644 --- a/packages/app/src/analytic-data-tracker/requests/track-unique-without-device-check.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/track-unique-without-device-check.request.ts @@ -4,14 +4,14 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" import { TrackEvent } from "App/analytic-data-tracker/types" export const trackUniqueWithoutDeviceCheckRequest = async ( event: TrackEvent ): Promise => { return ipcRenderer.callMain( - IpcAnalyticDataTrackerRequest.TrackUniqueWithoutDeviceCheck, + IpcAnalyticDataTrackerEvent.TrackUniqueWithoutDeviceCheck, event ) } diff --git a/packages/app/src/analytic-data-tracker/requests/track-unique.request.ts b/packages/app/src/analytic-data-tracker/requests/track-unique.request.ts index d426233c93..b883df4458 100644 --- a/packages/app/src/analytic-data-tracker/requests/track-unique.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/track-unique.request.ts @@ -4,9 +4,9 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" import { TrackEvent } from "App/analytic-data-tracker/types" export const trackUniqueRequest = async (event: TrackEvent): Promise => { - return ipcRenderer.callMain(IpcAnalyticDataTrackerRequest.TrackUnique, event) + return ipcRenderer.callMain(IpcAnalyticDataTrackerEvent.TrackUnique, event) } diff --git a/packages/app/src/analytic-data-tracker/requests/track-without-device-check.request.ts b/packages/app/src/analytic-data-tracker/requests/track-without-device-check.request.ts index bdab76cbb5..531819eab4 100644 --- a/packages/app/src/analytic-data-tracker/requests/track-without-device-check.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/track-without-device-check.request.ts @@ -4,14 +4,14 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" import { TrackEvent } from "App/analytic-data-tracker/types" export const trackWithoutDeviceCheckRequest = async ( event: TrackEvent ): Promise => { return ipcRenderer.callMain( - IpcAnalyticDataTrackerRequest.TrackWithoutDeviceCheck, + IpcAnalyticDataTrackerEvent.TrackWithoutDeviceCheck, event ) } diff --git a/packages/app/src/analytic-data-tracker/requests/track.request.ts b/packages/app/src/analytic-data-tracker/requests/track.request.ts index ee069af304..e58853c209 100644 --- a/packages/app/src/analytic-data-tracker/requests/track.request.ts +++ b/packages/app/src/analytic-data-tracker/requests/track.request.ts @@ -4,9 +4,9 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcAnalyticDataTrackerRequest } from "App/analytic-data-tracker/constants" +import { IpcAnalyticDataTrackerEvent } from "App/analytic-data-tracker/constants" import { TrackEvent } from "App/analytic-data-tracker/types" export const trackRequest = async (event: TrackEvent): Promise => { - return ipcRenderer.callMain(IpcAnalyticDataTrackerRequest.Track, event) + return ipcRenderer.callMain(IpcAnalyticDataTrackerEvent.Track, event) } diff --git a/packages/app/src/backup/constants/controller.constant.ts b/packages/app/src/backup/constants/controller.constant.ts index 847278ffa4..3feb5126d7 100644 --- a/packages/app/src/backup/constants/controller.constant.ts +++ b/packages/app/src/backup/constants/controller.constant.ts @@ -6,13 +6,7 @@ export const ControllerPrefix = "backup" export enum IpcBackupEvent { - LoadBackups = "load-backups", - CreateBackup = "create-backup", - RestoreBackup = "restore-backup", -} - -export enum IpcBackupRequest { - LoadBackups = "backup-load-backups", - CreateBackup = "backup-create-backup", - RestoreBackup = "backup-restore-backup", + LoadBackups = "backup_load-backups", + CreateBackup = "backup_create-backup", + RestoreBackup = "backup_restore-backup", } diff --git a/packages/app/src/backup/controllers/backup.controller.ts b/packages/app/src/backup/controllers/backup.controller.ts index 49cc25adc0..6e87d983c0 100644 --- a/packages/app/src/backup/controllers/backup.controller.ts +++ b/packages/app/src/backup/controllers/backup.controller.ts @@ -3,14 +3,10 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" import { Backup } from "App/backup/dto" -import { - BackupError, - ControllerPrefix, - IpcBackupEvent, -} from "App/backup/constants" +import { BackupError, IpcBackupEvent } from "App/backup/constants" import { BackupCreateService, BackupRestoreService, @@ -18,7 +14,6 @@ import { } from "App/backup/services" import { CreateDeviceBackup, RestoreDeviceBackup } from "App/backup/types" -@Controller(ControllerPrefix) export class BackupController { constructor( private backupCreateService: BackupCreateService, diff --git a/packages/app/src/backup/requests/create-backup.request.ts b/packages/app/src/backup/requests/create-backup.request.ts index 2e10092a4c..4e09e89ad5 100644 --- a/packages/app/src/backup/requests/create-backup.request.ts +++ b/packages/app/src/backup/requests/create-backup.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcBackupRequest } from "App/backup/constants" +import { IpcBackupEvent } from "App/backup/constants" import { CreateDeviceBackup } from "App/backup/types" export const createBackupRequest = async ( options: CreateDeviceBackup ): Promise> => { - return ipcRenderer.callMain(IpcBackupRequest.CreateBackup, options) + return ipcRenderer.callMain(IpcBackupEvent.CreateBackup, options) } diff --git a/packages/app/src/backup/requests/load-backups.request.ts b/packages/app/src/backup/requests/load-backups.request.ts index 06e27830ba..8994c82efd 100644 --- a/packages/app/src/backup/requests/load-backups.request.ts +++ b/packages/app/src/backup/requests/load-backups.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcBackupRequest } from "App/backup/constants" +import { IpcBackupEvent } from "App/backup/constants" import { Backup } from "App/backup/dto" export const loadBackupsRequest = async ( options: string ): Promise> => { - return ipcRenderer.callMain(IpcBackupRequest.LoadBackups, options) + return ipcRenderer.callMain(IpcBackupEvent.LoadBackups, options) } diff --git a/packages/app/src/backup/requests/restore-backup.request.ts b/packages/app/src/backup/requests/restore-backup.request.ts index 52507d91b9..6d37ef66cb 100644 --- a/packages/app/src/backup/requests/restore-backup.request.ts +++ b/packages/app/src/backup/requests/restore-backup.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { BackupError, IpcBackupRequest } from "App/backup/constants" +import { BackupError, IpcBackupEvent } from "App/backup/constants" import { RestoreDeviceBackup } from "App/backup/types" export const restoreBackupRequest = async ( options: RestoreDeviceBackup ): Promise> => { - return ipcRenderer.callMain(IpcBackupRequest.RestoreBackup, options) + return ipcRenderer.callMain(IpcBackupEvent.RestoreBackup, options) } diff --git a/packages/app/src/contacts/constants/controller.constant.ts b/packages/app/src/contacts/constants/controller.constant.ts index e260d139a9..e52d07deb8 100644 --- a/packages/app/src/contacts/constants/controller.constant.ts +++ b/packages/app/src/contacts/constants/controller.constant.ts @@ -3,16 +3,8 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "contact" - export enum IpcContactEvent { - CreateContact = "create-contact", - EditContact = "edit-contact", - DeleteContacts = "delete-contacts", -} - -export enum IpcContactRequest { - CreateContact = "contact-create-contact", - EditContact = "contact-edit-contact", - DeleteContacts = "contact-delete-contacts", + CreateContact = "contact_create-contact", + EditContact = "contact_edit-contact", + DeleteContacts = "contact_delete-contacts", } diff --git a/packages/app/src/contacts/controllers/contact.controller.ts b/packages/app/src/contacts/controllers/contact.controller.ts index bab91fb2d0..08bef10542 100644 --- a/packages/app/src/contacts/controllers/contact.controller.ts +++ b/packages/app/src/contacts/controllers/contact.controller.ts @@ -3,13 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ContactService } from "App/contacts/services" import { RequestResponse } from "App/core/types/request-response.interface" -import { ControllerPrefix, IpcContactEvent } from "App/contacts/constants" +import { IpcContactEvent } from "App/contacts/constants" import { Contact, ContactID } from "App/contacts/reducers" -@Controller(ControllerPrefix) export class ContactController { constructor(private contactService: ContactService) {} diff --git a/packages/app/src/contacts/requests/create-contact.request.ts b/packages/app/src/contacts/requests/create-contact.request.ts index 748851ac5f..c7e045177e 100644 --- a/packages/app/src/contacts/requests/create-contact.request.ts +++ b/packages/app/src/contacts/requests/create-contact.request.ts @@ -4,12 +4,12 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcContactRequest } from "App/contacts/constants" +import { IpcContactEvent } from "App/contacts/constants" import { Contact, NewContact } from "App/contacts/reducers/contacts.interface" import { RequestResponse } from "App/core/types/request-response.interface" export const createContactRequest = async ( newContact: NewContact ): Promise> => { - return ipcRenderer.callMain(IpcContactRequest.CreateContact, newContact) + return ipcRenderer.callMain(IpcContactEvent.CreateContact, newContact) } diff --git a/packages/app/src/contacts/requests/delete-contacts.request.ts b/packages/app/src/contacts/requests/delete-contacts.request.ts index 88b43907b1..78dedb4732 100644 --- a/packages/app/src/contacts/requests/delete-contacts.request.ts +++ b/packages/app/src/contacts/requests/delete-contacts.request.ts @@ -4,15 +4,12 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcContactRequest } from "App/contacts/constants" +import { IpcContactEvent } from "App/contacts/constants" import { ContactID } from "App/contacts/reducers/contacts.interface" import { RequestResponse } from "App/core/types/request-response.interface" export const deleteContactsRequest = async ( contactIds: ContactID[] ): Promise> => { - return await ipcRenderer.callMain( - IpcContactRequest.DeleteContacts, - contactIds - ) + return await ipcRenderer.callMain(IpcContactEvent.DeleteContacts, contactIds) } diff --git a/packages/app/src/contacts/requests/edit-contact.request.ts b/packages/app/src/contacts/requests/edit-contact.request.ts index 1f03d18202..c4066f034f 100644 --- a/packages/app/src/contacts/requests/edit-contact.request.ts +++ b/packages/app/src/contacts/requests/edit-contact.request.ts @@ -4,10 +4,12 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcContactRequest } from "App/contacts/constants" +import { IpcContactEvent } from "App/contacts/constants" import { Contact } from "App/contacts/reducers/contacts.interface" import { RequestResponse } from "App/core/types/request-response.interface" -export const editContactRequest = (contact: Contact): Promise> => { - return ipcRenderer.callMain(IpcContactRequest.EditContact, contact) +export const editContactRequest = ( + contact: Contact +): Promise> => { + return ipcRenderer.callMain(IpcContactEvent.EditContact, contact) } diff --git a/packages/app/src/core/application.module.ts b/packages/app/src/core/application.module.ts index 5398d90fd9..701595122f 100644 --- a/packages/app/src/core/application.module.ts +++ b/packages/app/src/core/application.module.ts @@ -21,7 +21,6 @@ import { } from "App/core/initializers" import { Module } from "App/core/types" import { FileSystemService } from "App/file-system/services/file-system.service.refactored" -import { FileSystemModule } from "App/file-system/file-system.module" import { IndexStorageModule } from "App/index-storage/index-storage.module" import { DataSyncModule } from "App/data-sync/data-sync.module" import { ContactModule } from "App/contacts/contact.module" @@ -48,7 +47,6 @@ import { export class ApplicationModule { public modules: Module[] = [ DeviceInfoModule, - FileSystemModule, IndexStorageModule, OutboxModule, AnalyticDataTrackerModule, diff --git a/packages/app/src/core/initializers/controller.initializer.ts b/packages/app/src/core/initializers/controller.initializer.ts index 4df8bda649..970c80dbfd 100644 --- a/packages/app/src/core/initializers/controller.initializer.ts +++ b/packages/app/src/core/initializers/controller.initializer.ts @@ -10,12 +10,6 @@ import { EventDefinition, Controller } from "App/core/types" export class ControllerInitializer { public initialize(controllers: Controller[]): void { controllers.forEach((controller) => { - // AUTO DISABLED - fix me if you like :) - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const prefix = Reflect.getMetadata( - ReflectKey.Prefix, - controller.constructor - ) // AUTO DISABLED - fix me if you like :) // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const events: EventDefinition[] = Reflect.getMetadata( @@ -26,7 +20,7 @@ export class ControllerInitializer { events.forEach((event) => { // AUTO DISABLED - fix me if you like :) // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/require-await - ipcMain.answerRenderer(`${prefix}-${event.name}`, async (data) => { + ipcMain.answerRenderer(event.name, (data) => { // AUTO DISABLED - fix me if you like :) // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-explicit-any return (controller as Record)[event.methodName](data) diff --git a/packages/app/src/crash-dump/constants/controller.constant.ts b/packages/app/src/crash-dump/constants/controller.constant.ts index 392c7c355e..c01b2b9a25 100644 --- a/packages/app/src/crash-dump/constants/controller.constant.ts +++ b/packages/app/src/crash-dump/constants/controller.constant.ts @@ -3,16 +3,8 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "crash-dump" - export enum IpcCrashDumpEvent { - Ignore = "ignore-file", - GetFiles = "get-files", - DownloadFiles = "download-files", -} - -export enum IpcCrashDumpRequest { - Ignore = "crash-dump-ignore-file", - GetFiles = "crash-dump-get-files", - DownloadCrashDump = "crash-dump-download-files", + Ignore = "crash-dump_ignore-file", + GetFiles = "crash-dump_get-files", + DownloadCrashDump = "crash-dump_download-files", } diff --git a/packages/app/src/crash-dump/controllers/crash-dump.controller.ts b/packages/app/src/crash-dump/controllers/crash-dump.controller.ts index 01f8900cfe..7642a94e77 100644 --- a/packages/app/src/crash-dump/controllers/crash-dump.controller.ts +++ b/packages/app/src/crash-dump/controllers/crash-dump.controller.ts @@ -3,20 +3,19 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { RequestResponse } from "App/core/types" import { SettingsService } from "App/settings/services" -import { ControllerPrefix, IpcCrashDumpEvent } from "App/crash-dump/constants" +import { IpcCrashDumpEvent } from "App/crash-dump/constants" import { CrashDumpService } from "App/crash-dump/services" -@Controller(ControllerPrefix) export class CrashDumpController { constructor( private crashDumpService: CrashDumpService, private settingsService: SettingsService ) {} - @IpcEvent(IpcCrashDumpEvent.DownloadFiles) + @IpcEvent(IpcCrashDumpEvent.DownloadCrashDump) public async downloadFile(): Promise> { const result = await this.crashDumpService.downloadDeviceCrashDumpFiles() this.settingsService.updateSettings({ diff --git a/packages/app/src/crash-dump/requests/download-crash-dump.request.ts b/packages/app/src/crash-dump/requests/download-crash-dump.request.ts index 8149db2139..b689a63f1d 100644 --- a/packages/app/src/crash-dump/requests/download-crash-dump.request.ts +++ b/packages/app/src/crash-dump/requests/download-crash-dump.request.ts @@ -5,10 +5,10 @@ import { ipcRenderer } from "electron-better-ipc" import { RequestResponse } from "App/core/types/request-response.interface" -import { IpcCrashDumpRequest } from "App/crash-dump/constants" +import { IpcCrashDumpEvent } from "App/crash-dump/constants" export const downloadCrashDumpRequest = async (): Promise< RequestResponse > => { - return ipcRenderer.callMain(IpcCrashDumpRequest.DownloadCrashDump) + return ipcRenderer.callMain(IpcCrashDumpEvent.DownloadCrashDump) } diff --git a/packages/app/src/crash-dump/requests/get-crash-dumps.request.ts b/packages/app/src/crash-dump/requests/get-crash-dumps.request.ts index c67cb95391..e1876ba507 100644 --- a/packages/app/src/crash-dump/requests/get-crash-dumps.request.ts +++ b/packages/app/src/crash-dump/requests/get-crash-dumps.request.ts @@ -5,10 +5,10 @@ import { ipcRenderer } from "electron-better-ipc" import { RequestResponse } from "App/core/types/request-response.interface" -import { IpcCrashDumpRequest } from "App/crash-dump/constants" +import { IpcCrashDumpEvent } from "App/crash-dump/constants" export const getCrashDumpsRequest = async (): Promise< RequestResponse > => { - return ipcRenderer.callMain(IpcCrashDumpRequest.GetFiles) + return ipcRenderer.callMain(IpcCrashDumpEvent.GetFiles) } diff --git a/packages/app/src/crash-dump/requests/ignore-crash-dump.request.ts b/packages/app/src/crash-dump/requests/ignore-crash-dump.request.ts index bde6a1c546..88694db34c 100644 --- a/packages/app/src/crash-dump/requests/ignore-crash-dump.request.ts +++ b/packages/app/src/crash-dump/requests/ignore-crash-dump.request.ts @@ -5,10 +5,10 @@ import { ipcRenderer } from "electron-better-ipc" import { RequestResponse } from "App/core/types/request-response.interface" -import { IpcCrashDumpRequest } from "App/crash-dump/constants" +import { IpcCrashDumpEvent } from "App/crash-dump/constants" export const ignoreCrashDumpRequest = async ( url: string ): Promise> => { - return ipcRenderer.callMain(IpcCrashDumpRequest.Ignore, url) + return ipcRenderer.callMain(IpcCrashDumpEvent.Ignore, url) } diff --git a/packages/app/src/data-sync/constants/controller.constant.ts b/packages/app/src/data-sync/constants/controller.constant.ts index 3a053876e6..b7afedea93 100644 --- a/packages/app/src/data-sync/constants/controller.constant.ts +++ b/packages/app/src/data-sync/constants/controller.constant.ts @@ -3,16 +3,8 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "data-sync" - export enum IpcDataSyncEvent { - GetIndex = "get-index", - IndexAll = "index-all", - InitializeDataSync = "initialize", -} - -export enum IpcDataSyncRequest { - GetIndex = "data-sync-get-index", - IndexAll = "data-sync-index-all", - InitializeDataSync = "data-sync-initialize", + GetIndex = "data-sync_get-index", + IndexAll = "data-sync_index-all", + InitializeDataSync = "data-sync_initialize", } diff --git a/packages/app/src/data-sync/controllers/data-sync.controller.ts b/packages/app/src/data-sync/controllers/data-sync.controller.ts index 785fa1b235..0bae874975 100644 --- a/packages/app/src/data-sync/controllers/data-sync.controller.ts +++ b/packages/app/src/data-sync/controllers/data-sync.controller.ts @@ -3,17 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { IndexStorage } from "App/index-storage/types" import { DataSyncService } from "App/data-sync/services/data-sync.service" -import { - ControllerPrefix, - IpcDataSyncEvent, - DataIndex, -} from "App/data-sync/constants" +import { IpcDataSyncEvent, DataIndex } from "App/data-sync/constants" import { SerialisedIndexData } from "elasticlunr" -@Controller(ControllerPrefix) export class DataSyncController { constructor( private index: IndexStorage, diff --git a/packages/app/src/data-sync/requests/get-index.request.test.ts b/packages/app/src/data-sync/requests/get-index.request.test.ts index ab1a449cce..5449758589 100644 --- a/packages/app/src/data-sync/requests/get-index.request.test.ts +++ b/packages/app/src/data-sync/requests/get-index.request.test.ts @@ -4,7 +4,7 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcDataSyncRequest, DataIndex } from "App/data-sync/constants" +import { IpcDataSyncEvent, DataIndex } from "App/data-sync/constants" import { getIndexRequest } from "App/data-sync/requests" import { SerialisedIndexData } from "elasticlunr" @@ -24,7 +24,7 @@ describe("`getIndexRequest`", () => { // AUTO DISABLED - fix me if you like :) // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any ;(ipcRenderer as any).__rendererCalls = { - [IpcDataSyncRequest.GetIndex]: getIndexResponse, + [IpcDataSyncEvent.GetIndex]: getIndexResponse, } const response = await getIndexRequest(DataIndex.Contact) expect(response).toEqual(getIndexResponse) diff --git a/packages/app/src/data-sync/requests/get-index.request.ts b/packages/app/src/data-sync/requests/get-index.request.ts index 9b3bc2b77c..2e10206d8a 100644 --- a/packages/app/src/data-sync/requests/get-index.request.ts +++ b/packages/app/src/data-sync/requests/get-index.request.ts @@ -5,12 +5,12 @@ import { ipcRenderer } from "electron-better-ipc" import { SerialisedIndexData } from "elasticlunr" -import { IpcDataSyncRequest, DataIndex } from "App/data-sync/constants" +import { IpcDataSyncEvent, DataIndex } from "App/data-sync/constants" // AUTO DISABLED - fix me if you like :) // eslint-disable-next-line @typescript-eslint/ban-types export const getIndexRequest = async ( indexName: DataIndex ): Promise | undefined> => { - return ipcRenderer.callMain(IpcDataSyncRequest.GetIndex, indexName) + return ipcRenderer.callMain(IpcDataSyncEvent.GetIndex, indexName) } diff --git a/packages/app/src/data-sync/requests/index-all.request.test.ts b/packages/app/src/data-sync/requests/index-all.request.test.ts index 58ddccc961..30495142b6 100644 --- a/packages/app/src/data-sync/requests/index-all.request.test.ts +++ b/packages/app/src/data-sync/requests/index-all.request.test.ts @@ -4,7 +4,7 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcDataSyncRequest } from "App/data-sync/constants" +import { IpcDataSyncEvent } from "App/data-sync/constants" import { indexAllRequest } from "App/data-sync/requests/index-all.request" describe("`indexAllRequest`", () => { @@ -12,7 +12,7 @@ describe("`indexAllRequest`", () => { // AUTO DISABLED - fix me if you like :) // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any ;(ipcRenderer as any).__rendererCalls = { - [IpcDataSyncRequest.IndexAll]: undefined, + [IpcDataSyncEvent.IndexAll]: undefined, } const response = await indexAllRequest() expect(response).toBeUndefined() diff --git a/packages/app/src/data-sync/requests/index-all.request.ts b/packages/app/src/data-sync/requests/index-all.request.ts index 578baa3e55..e9dac7d0da 100644 --- a/packages/app/src/data-sync/requests/index-all.request.ts +++ b/packages/app/src/data-sync/requests/index-all.request.ts @@ -4,8 +4,8 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcDataSyncRequest } from "App/data-sync/constants" +import { IpcDataSyncEvent } from "App/data-sync/constants" export const indexAllRequest = async (): Promise => { - return ipcRenderer.callMain(IpcDataSyncRequest.IndexAll) + return ipcRenderer.callMain(IpcDataSyncEvent.IndexAll) } diff --git a/packages/app/src/data-sync/requests/initialize-data-sync.request.ts b/packages/app/src/data-sync/requests/initialize-data-sync.request.ts index 47e35d2f3d..516c4167c5 100644 --- a/packages/app/src/data-sync/requests/initialize-data-sync.request.ts +++ b/packages/app/src/data-sync/requests/initialize-data-sync.request.ts @@ -4,11 +4,11 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcDataSyncRequest } from "App/data-sync/constants" +import { IpcDataSyncEvent } from "App/data-sync/constants" import { InitializeOptions } from "App/data-sync/types" export const initializeDataSyncRequest = async ( options: InitializeOptions ): Promise => { - return ipcRenderer.callMain(IpcDataSyncRequest.InitializeDataSync, options) + return ipcRenderer.callMain(IpcDataSyncEvent.InitializeDataSync, options) } diff --git a/packages/app/src/device-file-system/constants/controller.constant.ts b/packages/app/src/device-file-system/constants/controller.constant.ts index 4746ccefb6..28e2c5743b 100644 --- a/packages/app/src/device-file-system/constants/controller.constant.ts +++ b/packages/app/src/device-file-system/constants/controller.constant.ts @@ -3,18 +3,9 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "device-file-system" - export enum IpcDeviceFileSystemEvent { - DownloadDeviceFiles = "download-device-files", - RemoveDeviceFile = "remove-device-file", - UploadFileLocally = "upload-file-locally", - UploadFileToDevice = "upload-file-to-device", -} - -export enum IpcDeviceFileSystemRequest { - DownloadDeviceFiles = "device-file-system-download-device-files", - RemoveDeviceFile = "device-file-system-remove-device-file", - UploadFileLocally = "device-file-system-upload-file-locally", - UploadFileToDevice = "device-file-system-upload-file-to-device", + DownloadDeviceFiles = "device-file-system_download-device-files", + RemoveDeviceFile = "device-file-system_remove-device-file", + UploadFileLocally = "device-file-system_upload-file-locally", + UploadFileToDevice = "device-file-system_upload-file-to-device", } diff --git a/packages/app/src/device-file-system/controllers/device-file-system.controller.ts b/packages/app/src/device-file-system/controllers/device-file-system.controller.ts index 080542e8b3..d14f4b5b3b 100644 --- a/packages/app/src/device-file-system/controllers/device-file-system.controller.ts +++ b/packages/app/src/device-file-system/controllers/device-file-system.controller.ts @@ -4,11 +4,8 @@ */ import { ResultObject } from "App/core/builder" -import { Controller, IpcEvent } from "App/core/decorators" -import { - ControllerPrefix, - IpcDeviceFileSystemEvent, -} from "App/device-file-system/constants" +import { IpcEvent } from "App/core/decorators" +import { IpcDeviceFileSystemEvent } from "App/device-file-system/constants" import { DeviceFileSystemService } from "App/device-file-system/services" import { UploadFile, @@ -16,7 +13,6 @@ import { DeviceFile, } from "App/device-file-system/dto" -@Controller(ControllerPrefix) export class DeviceFileSystemController { constructor(private deviceFileSystemService: DeviceFileSystemService) {} diff --git a/packages/app/src/device-file-system/requests/download-device-file.request.ts b/packages/app/src/device-file-system/requests/download-device-file.request.ts index 40f621819f..44c6430c8c 100644 --- a/packages/app/src/device-file-system/requests/download-device-file.request.ts +++ b/packages/app/src/device-file-system/requests/download-device-file.request.ts @@ -5,14 +5,14 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceFileSystemRequest } from "App/device-file-system/constants" +import { IpcDeviceFileSystemEvent } from "App/device-file-system/constants" import { DeviceFile } from "App/device-file-system/dto" export const downloadDeviceFiles = async ( filePaths: string[] ): Promise> => { return ipcRenderer.callMain( - IpcDeviceFileSystemRequest.DownloadDeviceFiles, + IpcDeviceFileSystemEvent.DownloadDeviceFiles, filePaths ) } diff --git a/packages/app/src/device-file-system/requests/remove-file.request.ts b/packages/app/src/device-file-system/requests/remove-file.request.ts index 27f6306d18..9b9b1e652d 100644 --- a/packages/app/src/device-file-system/requests/remove-file.request.ts +++ b/packages/app/src/device-file-system/requests/remove-file.request.ts @@ -5,9 +5,9 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceFileSystemRequest } from "App/device-file-system/constants" +import { IpcDeviceFileSystemEvent } from "App/device-file-system/constants" export const removeFileRequest = ( filePath: string ): Promise> => - ipcRenderer.callMain(IpcDeviceFileSystemRequest.RemoveDeviceFile, filePath) + ipcRenderer.callMain(IpcDeviceFileSystemEvent.RemoveDeviceFile, filePath) diff --git a/packages/app/src/device-file-system/requests/upload-device-file-locally.request.ts b/packages/app/src/device-file-system/requests/upload-device-file-locally.request.ts index 37d7b69a7a..dee38639d5 100644 --- a/packages/app/src/device-file-system/requests/upload-device-file-locally.request.ts +++ b/packages/app/src/device-file-system/requests/upload-device-file-locally.request.ts @@ -5,14 +5,14 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceFileSystemRequest } from "App/device-file-system/constants" +import { IpcDeviceFileSystemEvent } from "App/device-file-system/constants" import { UploadFileLocally, DeviceFile } from "App/device-file-system/dto" export const uploadDeviceFileLocally = async ( payload: UploadFileLocally ): Promise> => { return ipcRenderer.callMain( - IpcDeviceFileSystemRequest.UploadFileLocally, + IpcDeviceFileSystemEvent.UploadFileLocally, payload ) } diff --git a/packages/app/src/device-file-system/requests/upload-device-file.request.ts b/packages/app/src/device-file-system/requests/upload-device-file.request.ts index 64f3740560..507ac9bb02 100644 --- a/packages/app/src/device-file-system/requests/upload-device-file.request.ts +++ b/packages/app/src/device-file-system/requests/upload-device-file.request.ts @@ -5,14 +5,14 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceFileSystemRequest } from "App/device-file-system/constants" +import { IpcDeviceFileSystemEvent } from "App/device-file-system/constants" import { UploadFile } from "App/device-file-system/dto" export const uploadDeviceFile = async ( payload: UploadFile ): Promise> => { return ipcRenderer.callMain( - IpcDeviceFileSystemRequest.UploadFileToDevice, + IpcDeviceFileSystemEvent.UploadFileToDevice, payload ) } diff --git a/packages/app/src/device-info/constants/controller.constant.ts b/packages/app/src/device-info/constants/controller.constant.ts index 2ed4b44e33..6987affae8 100644 --- a/packages/app/src/device-info/constants/controller.constant.ts +++ b/packages/app/src/device-info/constants/controller.constant.ts @@ -3,12 +3,6 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "device-info" - export enum IpcDeviceInfoEvent { - GetDeviceInfo = "get-device-info", -} - -export enum IpcDeviceInfoRequest { - GetDeviceInfo = "device-info-get-device-info", + GetDeviceInfo = "device-info_get-device-info", } diff --git a/packages/app/src/device-info/controllers/device-info.controller.ts b/packages/app/src/device-info/controllers/device-info.controller.ts index b9a040d6bb..bf397714b5 100644 --- a/packages/app/src/device-info/controllers/device-info.controller.ts +++ b/packages/app/src/device-info/controllers/device-info.controller.ts @@ -3,13 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" import { DeviceInfo } from "App/device-info/dto" import { DeviceInfoService } from "App/device-info/services" -import { ControllerPrefix, IpcDeviceInfoEvent } from "App/device-info/constants" +import { IpcDeviceInfoEvent } from "App/device-info/constants" -@Controller(ControllerPrefix) export class DeviceInfoController { constructor(private deviceInfoService: DeviceInfoService) {} diff --git a/packages/app/src/device-info/requests/get-device-info.request.ts b/packages/app/src/device-info/requests/get-device-info.request.ts index ab94bad348..078c5b87cf 100644 --- a/packages/app/src/device-info/requests/get-device-info.request.ts +++ b/packages/app/src/device-info/requests/get-device-info.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceInfoRequest } from "App/device-info/constants" +import { IpcDeviceInfoEvent } from "App/device-info/constants" import { DeviceInfo } from "App/device-info/dto" export const getDeviceInfoRequest = async (): Promise< ResultObject > => { - return ipcRenderer.callMain(IpcDeviceInfoRequest.GetDeviceInfo) + return ipcRenderer.callMain(IpcDeviceInfoEvent.GetDeviceInfo) } diff --git a/packages/app/src/device-log/constants/controller.constant.ts b/packages/app/src/device-log/constants/controller.constant.ts index f3e9e9e13d..d1fa3d94be 100644 --- a/packages/app/src/device-log/constants/controller.constant.ts +++ b/packages/app/src/device-log/constants/controller.constant.ts @@ -3,12 +3,6 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "device-log" - export enum IpcDeviceLogEvent { - GetLog = "get-log", -} - -export enum IpcDeviceLogRequest { - GetLog = "device-log-get-log", + GetLog = "device-log_get-log", } diff --git a/packages/app/src/device-log/controllers/device-log.controller.ts b/packages/app/src/device-log/controllers/device-log.controller.ts index ca56cf8a7d..29918386f3 100644 --- a/packages/app/src/device-log/controllers/device-log.controller.ts +++ b/packages/app/src/device-log/controllers/device-log.controller.ts @@ -3,14 +3,13 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" import { DeviceLogService } from "App/device-log/services" -import { ControllerPrefix, IpcDeviceLogEvent } from "App/device-log/constants" +import { IpcDeviceLogEvent } from "App/device-log/constants" import { DeviceFile } from "App/device-file-system/dto" import { DeviceFilesOption } from "App/device-file-system/types" -@Controller(ControllerPrefix) export class DeviceLogController { constructor(private deviceInfoService: DeviceLogService) {} diff --git a/packages/app/src/device-log/requests/get-device-log-files.request.ts b/packages/app/src/device-log/requests/get-device-log-files.request.ts index 6881c7562c..276722a856 100644 --- a/packages/app/src/device-log/requests/get-device-log-files.request.ts +++ b/packages/app/src/device-log/requests/get-device-log-files.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceLogRequest } from "App/device-log/constants" +import { IpcDeviceLogEvent } from "App/device-log/constants" import { DeviceFilesOption } from "App/device-file-system/types" import { DeviceFile } from "App/device-file-system/dto" export const getDeviceLogFiles = async ( options?: DeviceFilesOption ): Promise> => - ipcRenderer.callMain(IpcDeviceLogRequest.GetLog, options) + ipcRenderer.callMain(IpcDeviceLogEvent.GetLog, options) diff --git a/packages/app/src/device-manager/constants/controller.constant.ts b/packages/app/src/device-manager/constants/controller.constant.ts index 557bce39c9..e67f926bcc 100644 --- a/packages/app/src/device-manager/constants/controller.constant.ts +++ b/packages/app/src/device-manager/constants/controller.constant.ts @@ -6,13 +6,5 @@ export const ControllerPrefix = "device-manager" export enum IpcDeviceManagerEvent { - GetDevices = "get-devices", - GetCurrentDevice = "get-current-device", - SetCurrentDevice = "set-current-device", -} - -export enum IpcDeviceManagerRequest { - GetDevices = "device-manager-get-devices", - GetCurrentDevice = "device-manager-get-current-device", - SetCurrentDevice = "device-manager-set-current-device", + GetCurrentDevice = "device-manager_get-current-device", } diff --git a/packages/app/src/device-manager/controllers/device-manager.controller.ts b/packages/app/src/device-manager/controllers/device-manager.controller.ts index aa6d8dd9ff..bffd0387dd 100644 --- a/packages/app/src/device-manager/controllers/device-manager.controller.ts +++ b/packages/app/src/device-manager/controllers/device-manager.controller.ts @@ -3,17 +3,13 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject, Result } from "App/core/builder" import { AppError } from "App/core/errors" import { DeviceManager } from "App/device-manager/services" -import { - ControllerPrefix, - IpcDeviceManagerEvent, -} from "App/device-manager/constants" +import { IpcDeviceManagerEvent } from "App/device-manager/constants" import { Device } from "App/device/modules/device" -@Controller(ControllerPrefix) export class DeviceManagerController { constructor(private deviceManager: DeviceManager) {} @@ -25,14 +21,4 @@ export class DeviceManagerController { return Result.failed(error as AppError) } } - - @IpcEvent(IpcDeviceManagerEvent.GetDevices) - public getDevices(): ResultObject { - return Result.success(this.deviceManager.devices) - } - - @IpcEvent(IpcDeviceManagerEvent.SetCurrentDevice) - public setCurrentDevice(path: string): ResultObject { - return this.deviceManager.setCurrentDevice(path) - } } diff --git a/packages/app/src/device-manager/requests/get-current-device.request.ts b/packages/app/src/device-manager/requests/get-current-device.request.ts index ab257a6842..93c74bb729 100644 --- a/packages/app/src/device-manager/requests/get-current-device.request.ts +++ b/packages/app/src/device-manager/requests/get-current-device.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceManagerRequest } from "App/device-manager/constants" +import { IpcDeviceManagerEvent } from "App/device-manager/constants" import { Device } from "App/device/modules/device" export const getCurrentDeviceRequest = async (): Promise< ResultObject > => { - return ipcRenderer.callMain(IpcDeviceManagerRequest.GetCurrentDevice) + return ipcRenderer.callMain(IpcDeviceManagerEvent.GetCurrentDevice) } diff --git a/packages/app/src/device/constants/controller.constant.ts b/packages/app/src/device/constants/controller.constant.ts index b2bed9f3fe..180c638680 100644 --- a/packages/app/src/device/constants/controller.constant.ts +++ b/packages/app/src/device/constants/controller.constant.ts @@ -3,20 +3,10 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "device" - export enum IpcDeviceEvent { - Connect = "connect", - Unlock = "unlock", - UnlockStatus = "unlock-status", - LockTime = "lock-time", - SetUpdating = "set-updating", -} - -export enum IpcDeviceRequest { - Connect = "device-connect", - Unlock = "device-unlock", - UnlockStatus = "device-unlock-status", - LockTime = "device-lock-time", - SetUpdating = "device-set-updating", + Connect = "device_connect", + Unlock = "device_unlock", + UnlockStatus = "device_unlock-status", + LockTime = "device_lock-time", + SetUpdating = "device_set-updating", } diff --git a/packages/app/src/device/controllers/device.controller.ts b/packages/app/src/device/controllers/device.controller.ts index 84ac41d1fb..6468b916fa 100644 --- a/packages/app/src/device/controllers/device.controller.ts +++ b/packages/app/src/device/controllers/device.controller.ts @@ -3,14 +3,13 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" import { DeviceService } from "App/device/services" import { PhoneLockTime } from "App/device/dto" -import { ControllerPrefix, IpcDeviceEvent } from "App/device/constants" +import { IpcDeviceEvent } from "App/device/constants" import { DeviceInfo } from "App/device/types/mudita-os" -@Controller(ControllerPrefix) export class DeviceController { constructor(private deviceService: DeviceService) {} diff --git a/packages/app/src/device/requests/connect-device.request.ts b/packages/app/src/device/requests/connect-device.request.ts index 98c8565246..b0409cb6e2 100644 --- a/packages/app/src/device/requests/connect-device.request.ts +++ b/packages/app/src/device/requests/connect-device.request.ts @@ -5,9 +5,9 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceRequest } from "App/device/constants" +import { IpcDeviceEvent } from "App/device/constants" import { Device } from "App/device/modules/device" export const connectDeviceRequest = async (): Promise> => { - return ipcRenderer.callMain(IpcDeviceRequest.Connect) + return ipcRenderer.callMain(IpcDeviceEvent.Connect) } diff --git a/packages/app/src/device/requests/device-lock-time.request.ts b/packages/app/src/device/requests/device-lock-time.request.ts index ba384a8db3..fc8a33bdca 100644 --- a/packages/app/src/device/requests/device-lock-time.request.ts +++ b/packages/app/src/device/requests/device-lock-time.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceRequest } from "App/device/constants" +import { IpcDeviceEvent } from "App/device/constants" import { PhoneLockTime } from "App/device/dto" export const deviceLockTimeRequest = async (): Promise< ResultObject > => { - return ipcRenderer.callMain(IpcDeviceRequest.LockTime) + return ipcRenderer.callMain(IpcDeviceEvent.LockTime) } diff --git a/packages/app/src/device/requests/set-updating.request.ts b/packages/app/src/device/requests/set-updating.request.ts index 84fe235278..d8850a5122 100644 --- a/packages/app/src/device/requests/set-updating.request.ts +++ b/packages/app/src/device/requests/set-updating.request.ts @@ -4,11 +4,11 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcDeviceRequest } from "App/device/constants" +import { IpcDeviceEvent } from "App/device/constants" // This request is a tmp solution to manage `updating` state in `deviceManager` class // The tech debt will be fixed as part ot tech task // https://appnroll.atlassian.net/browse/CP-1765 export const setUpdatingRequest = async (updating: boolean): Promise => { - return ipcRenderer.callMain(IpcDeviceRequest.SetUpdating, updating) + return ipcRenderer.callMain(IpcDeviceEvent.SetUpdating, updating) } diff --git a/packages/app/src/device/requests/unlock-device-status.request.ts b/packages/app/src/device/requests/unlock-device-status.request.ts index 94b5de0952..5d883d3588 100644 --- a/packages/app/src/device/requests/unlock-device-status.request.ts +++ b/packages/app/src/device/requests/unlock-device-status.request.ts @@ -5,13 +5,10 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { - DeviceCommunicationError, - IpcDeviceRequest, -} from "App/device/constants" +import { DeviceCommunicationError, IpcDeviceEvent } from "App/device/constants" export const unlockDeviceStatusRequest = async (): Promise< ResultObject > => { - return ipcRenderer.callMain(IpcDeviceRequest.UnlockStatus) + return ipcRenderer.callMain(IpcDeviceEvent.UnlockStatus) } diff --git a/packages/app/src/device/requests/unlock-device.request.ts b/packages/app/src/device/requests/unlock-device.request.ts index ffeadd9238..e3109f017a 100644 --- a/packages/app/src/device/requests/unlock-device.request.ts +++ b/packages/app/src/device/requests/unlock-device.request.ts @@ -5,10 +5,10 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcDeviceRequest } from "App/device/constants" +import { IpcDeviceEvent } from "App/device/constants" export const unlockDeviceRequest = async ( code: number[] ): Promise> => { - return ipcRenderer.callMain(IpcDeviceRequest.Unlock, code) + return ipcRenderer.callMain(IpcDeviceEvent.Unlock, code) } diff --git a/packages/app/src/file-system/constants/controller.constant.ts b/packages/app/src/file-system/constants/controller.constant.ts deleted file mode 100644 index d65f9ad300..0000000000 --- a/packages/app/src/file-system/constants/controller.constant.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export const DialogControllerPrefix = "dialog-file-system" - -export enum IpcDialogFileSystemEvent { - GetPaths = "get-paths", -} - -export enum IpcDialogFileSystemRequest { - GetPaths = "dialog-file-system-get-paths", -} diff --git a/packages/app/src/file-system/constants/error.constant.ts b/packages/app/src/file-system/constants/error.constant.ts deleted file mode 100644 index 084bf0c6cb..0000000000 --- a/packages/app/src/file-system/constants/error.constant.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export enum DialogFileSystemError { - GetPath = "CANT_GET_SELECTED_FILES_PATH_ERROR", -} diff --git a/packages/app/src/file-system/constants/index.ts b/packages/app/src/file-system/constants/index.ts deleted file mode 100644 index dd30a7d30a..0000000000 --- a/packages/app/src/file-system/constants/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./controller.constant" -export * from "./error.constant" -export * from "./ipc-file-system.enum" diff --git a/packages/app/src/file-system/constants/ipc-file-system.enum.ts b/packages/app/src/file-system/constants/ipc-file-system.enum.ts deleted file mode 100644 index 753d4f3efd..0000000000 --- a/packages/app/src/file-system/constants/ipc-file-system.enum.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export enum IpcFileSystem { - EncryptFile = "file-system-encrypt-file", - DecryptFile = "file-system-decrypt-file", - ReadFile = "file-system-read-file", - UnlinkFile = "file-system-unlink-file", -} diff --git a/packages/app/src/file-system/controllers/dialog-file-system.controller.ts b/packages/app/src/file-system/controllers/dialog-file-system.controller.ts deleted file mode 100644 index ca274c0d94..0000000000 --- a/packages/app/src/file-system/controllers/dialog-file-system.controller.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { Controller, IpcEvent } from "App/core/decorators" -import { ResultObject } from "App/core/builder" -import { - DialogControllerPrefix, - IpcDialogFileSystemEvent, -} from "App/file-system/constants" -import { GetPathsInput } from "App/file-system/dto" -import { FilesSystemDialogService } from "App/file-system/services/file-system-dialog.service" - -@Controller(DialogControllerPrefix) -export class DialogFileSystemController { - constructor(private filesSystemDialogService: FilesSystemDialogService) {} - - @IpcEvent(IpcDialogFileSystemEvent.GetPaths) - public async getPaths({ - filters = [], - properties, - }: GetPathsInput): Promise> { - return this.filesSystemDialogService.getPaths(filters, properties) - } -} diff --git a/packages/app/src/file-system/controllers/index.ts b/packages/app/src/file-system/controllers/index.ts deleted file mode 100644 index cff9f81cc0..0000000000 --- a/packages/app/src/file-system/controllers/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./dialog-file-system.controller" diff --git a/packages/app/src/file-system/dto/get-paths-input.object.ts b/packages/app/src/file-system/dto/get-paths-input.object.ts deleted file mode 100644 index f0dc7b3f18..0000000000 --- a/packages/app/src/file-system/dto/get-paths-input.object.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { FileFilter, OpenDialogOptions } from "electron" - -export interface GetPathsInput { - filters: FileFilter[] - properties: OpenDialogOptions["properties"] -} diff --git a/packages/app/src/file-system/dto/index.ts b/packages/app/src/file-system/dto/index.ts deleted file mode 100644 index 22669858f8..0000000000 --- a/packages/app/src/file-system/dto/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./get-paths-input.object" diff --git a/packages/app/src/file-system/file-system.module.ts b/packages/app/src/file-system/file-system.module.ts deleted file mode 100644 index 4ffb0fc895..0000000000 --- a/packages/app/src/file-system/file-system.module.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { MainProcessIpc } from "electron-better-ipc" -import { EventEmitter } from "events" -import { MetadataStore } from "App/metadata/services" -import { FileSystemService } from "App/file-system/services/file-system.service.refactored" -import { AppLogger } from "App/__deprecated__/main/utils/logger" -import { IndexStorage } from "App/index-storage/types" -import { BaseModule } from "App/core/module" -import { FilesSystemDialogService } from "App/file-system/services" -import { DialogFileSystemController } from "App/file-system/controllers" -import { DeviceManager } from "App/device-manager/services" - -export class FileSystemModule extends BaseModule { - constructor( - public index: IndexStorage, - public deviceManager: DeviceManager, - public keyStorage: MetadataStore, - public logger: AppLogger, - public ipc: MainProcessIpc, - public eventEmitter: EventEmitter, - public fileSystem: FileSystemService - ) { - super( - index, - deviceManager, - keyStorage, - logger, - ipc, - eventEmitter, - fileSystem - ) - - const filesSystemDialogService = new FilesSystemDialogService() - const dialogFileSystemController = new DialogFileSystemController( - filesSystemDialogService - ) - - this.controllers = [dialogFileSystemController] - } -} diff --git a/packages/app/src/file-system/helpers/array-buffer-to-buffer.test.ts b/packages/app/src/file-system/helpers/array-buffer-to-buffer.test.ts deleted file mode 100644 index 9cb69e5180..0000000000 --- a/packages/app/src/file-system/helpers/array-buffer-to-buffer.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { arrayBufferToBuffer } from "App/file-system/helpers/array-buffer-to-buffer" - -describe("`arrayBufferToBuffer` function", () => { - const data = [1, 2, 3, 4, 5] - - test("Uint8Array constructor isn't equal to buffer", () => { - const bufferView = new Uint8Array(data) - expect(bufferView.constructor).not.toBe(Buffer) - expect(bufferView.constructor).toBe(Uint8Array) - }) - - test("mapped buffer return buffer as constructor", () => { - const buffer = arrayBufferToBuffer(new Uint8Array(data)) - expect(buffer.constructor).not.toBe(Uint8Array) - expect(buffer.constructor).toBe(Buffer) - }) -}) diff --git a/packages/app/src/file-system/helpers/array-buffer-to-buffer.ts b/packages/app/src/file-system/helpers/array-buffer-to-buffer.ts deleted file mode 100644 index c4e08b260f..0000000000 --- a/packages/app/src/file-system/helpers/array-buffer-to-buffer.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -/** - * Uint8Array is a general-purpose byte-array that’s available in both nodejs and browsers. - * Buffer is a subclass of Uint8Array that’s only available in nodejs - */ - -export const arrayBufferToBuffer = (ab: Uint8Array): Buffer => { - const buffer = Buffer.alloc(ab.byteLength) - const view = new Uint8Array(ab) - for (let i = 0; i < buffer.length; ++i) { - buffer[i] = view[i] - } - return buffer -} diff --git a/packages/app/src/file-system/helpers/index.ts b/packages/app/src/file-system/helpers/index.ts deleted file mode 100644 index 0d2e34f3d9..0000000000 --- a/packages/app/src/file-system/helpers/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./array-buffer-to-buffer" diff --git a/packages/app/src/file-system/listeners/decrypt-file.listener.ts b/packages/app/src/file-system/listeners/decrypt-file.listener.ts deleted file mode 100644 index b366cf7edb..0000000000 --- a/packages/app/src/file-system/listeners/decrypt-file.listener.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcMain } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants/ipc-file-system.enum" -import CryptoFileService, { - CryptoFileOptions, -} from "App/file-system/services/crypto-file-service/crypto-file-service" - -const registerDecryptFileListener = (): void => { - ipcMain.answerRenderer( - IpcFileSystem.DecryptFile, - // AUTO DISABLED - fix me if you like :) - // eslint-disable-next-line @typescript-eslint/unbound-method - CryptoFileService.decrypt - ) -} - -export default registerDecryptFileListener diff --git a/packages/app/src/file-system/listeners/encrypt-file.listener.ts b/packages/app/src/file-system/listeners/encrypt-file.listener.ts deleted file mode 100644 index 57f3214b81..0000000000 --- a/packages/app/src/file-system/listeners/encrypt-file.listener.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcMain } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants/ipc-file-system.enum" -import CryptoFileService, { - CryptoFileOptions, -} from "App/file-system/services/crypto-file-service/crypto-file-service" - -const registerEncryptFileListener = (): void => { - ipcMain.answerRenderer( - IpcFileSystem.EncryptFile, - // AUTO DISABLED - fix me if you like :) - // eslint-disable-next-line @typescript-eslint/unbound-method - CryptoFileService.encrypt - ) -} - -export default registerEncryptFileListener diff --git a/packages/app/src/file-system/listeners/index.ts b/packages/app/src/file-system/listeners/index.ts deleted file mode 100644 index 2eed4e6c1b..0000000000 --- a/packages/app/src/file-system/listeners/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./decrypt-file.listener" -export * from "./encrypt-file.listener" -export * from "./read-file.listener" -export * from "./unlink-file.listener" diff --git a/packages/app/src/file-system/listeners/read-file.listener.ts b/packages/app/src/file-system/listeners/read-file.listener.ts deleted file mode 100644 index e09dc0f83c..0000000000 --- a/packages/app/src/file-system/listeners/read-file.listener.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import fs, { PathOrFileDescriptor } from "fs" -import { ipcMain } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants/ipc-file-system.enum" - -const registerReadFileListener = (): void => { - ipcMain.answerRenderer( - IpcFileSystem.ReadFile, - (path) => { - return fs.readFileSync(path) - } - ) -} - -export default registerReadFileListener diff --git a/packages/app/src/file-system/listeners/unlink-file.listener.ts b/packages/app/src/file-system/listeners/unlink-file.listener.ts deleted file mode 100644 index fbff2d3598..0000000000 --- a/packages/app/src/file-system/listeners/unlink-file.listener.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcMain } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants/ipc-file-system.enum" -import fs, { PathLike } from "fs" - -export const unlinkSync = (path: PathLike): void => { - return fs.unlinkSync(path) -} - -const registerUnlinkFileListener = (): void => { - ipcMain.answerRenderer( - IpcFileSystem.UnlinkFile, - unlinkSync - ) -} - -export default registerUnlinkFileListener diff --git a/packages/app/src/file-system/requests/decrypt-file.request.ts b/packages/app/src/file-system/requests/decrypt-file.request.ts deleted file mode 100644 index d47097ee45..0000000000 --- a/packages/app/src/file-system/requests/decrypt-file.request.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcRenderer } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants" -import { CryptoFileOptions } from "App/file-system/services/crypto-file-service/crypto-file-service" - -const decryptFile = async ( - options: CryptoFileOptions -): Promise => { - return await ipcRenderer.callMain(IpcFileSystem.DecryptFile, options) -} - -export default decryptFile diff --git a/packages/app/src/file-system/requests/encrypt-file.request.ts b/packages/app/src/file-system/requests/encrypt-file.request.ts deleted file mode 100644 index 75313e249c..0000000000 --- a/packages/app/src/file-system/requests/encrypt-file.request.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcRenderer } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants" -import { CryptoFileOptions } from "App/file-system/services/crypto-file-service/crypto-file-service" - -const encryptFile = async ( - options: CryptoFileOptions -): Promise => { - return await ipcRenderer.callMain(IpcFileSystem.EncryptFile, options) -} - -export default encryptFile diff --git a/packages/app/src/file-system/requests/get-paths.request.ts b/packages/app/src/file-system/requests/get-paths.request.ts deleted file mode 100644 index 87af4faeaf..0000000000 --- a/packages/app/src/file-system/requests/get-paths.request.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcRenderer } from "electron-better-ipc" -import { ResultObject } from "App/core/builder" -import { IpcDialogFileSystemRequest } from "App/file-system/constants" -import { GetPathsInput } from "App/file-system/dto" - -export const getPathsRequest = async ( - props: GetPathsInput -): Promise> => { - return ipcRenderer.callMain(IpcDialogFileSystemRequest.GetPaths, props) -} diff --git a/packages/app/src/file-system/requests/index.ts b/packages/app/src/file-system/requests/index.ts deleted file mode 100644 index c05e9141cc..0000000000 --- a/packages/app/src/file-system/requests/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./get-paths.request" diff --git a/packages/app/src/file-system/requests/read-file.request.ts b/packages/app/src/file-system/requests/read-file.request.ts deleted file mode 100644 index 2a0d150348..0000000000 --- a/packages/app/src/file-system/requests/read-file.request.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { PathOrFileDescriptor } from "fs" -import { ipcRenderer } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants" - -const readFile = async ( - path: PathOrFileDescriptor -): Promise => { - return await ipcRenderer.callMain(IpcFileSystem.ReadFile, path) -} - -export default readFile diff --git a/packages/app/src/file-system/requests/unlink-file.request.ts b/packages/app/src/file-system/requests/unlink-file.request.ts deleted file mode 100644 index 92d695a13e..0000000000 --- a/packages/app/src/file-system/requests/unlink-file.request.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { ipcRenderer } from "electron-better-ipc" -import { IpcFileSystem } from "App/file-system/constants" -import { PathLike } from "fs" - -const unlinkFile = async ( - path: PathLike -): Promise => { - return await ipcRenderer.callMain(IpcFileSystem.UnlinkFile, path) -} - -export default unlinkFile diff --git a/packages/app/src/file-system/services/file-system-dialog.service.test.ts b/packages/app/src/file-system/services/file-system-dialog.service.test.ts deleted file mode 100644 index c82f4757d3..0000000000 --- a/packages/app/src/file-system/services/file-system-dialog.service.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { dialog } from "electron" -import { Result } from "App/core/builder" -import { AppError } from "App/core/errors" -import { FilesSystemDialogService } from "App/file-system/services/file-system-dialog.service" -import { DialogFileSystemError } from "App/file-system/constants" - -jest.mock("electron", () => ({ - dialog: { - showOpenDialog: jest.fn(), - }, -})) - -const subject = new FilesSystemDialogService() - -beforeEach(() => [jest.resetAllMocks()]) - -test("returns `Result.success` with selected files list", async () => { - ;(dialog.showOpenDialog as jest.Mock).mockResolvedValueOnce({ - filePaths: ["/test/file-1.txt"], - }) - - const result = await subject.getPaths() - expect(result).toEqual(Result.success(["/test/file-1.txt"])) -}) - -test("returns `Result.failed` if `showOpenDialog` throw an error", async () => { - ;(dialog.showOpenDialog as jest.Mock).mockRejectedValueOnce( - new Error("Luke, I'm your error") - ) - - const result = await subject.getPaths() - expect(result).toEqual( - Result.failed( - new AppError(DialogFileSystemError.GetPath, "Luke, I'm your error") - ) - ) -}) diff --git a/packages/app/src/file-system/services/file-system-dialog.service.ts b/packages/app/src/file-system/services/file-system-dialog.service.ts deleted file mode 100644 index 4fe565e6ef..0000000000 --- a/packages/app/src/file-system/services/file-system-dialog.service.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -import { dialog, FileFilter, OpenDialogOptions } from "electron" -import { AppError } from "App/core/errors" -import { Result, ResultObject } from "App/core/builder" -import { DialogFileSystemError } from "App/file-system/constants" - -export class FilesSystemDialogService { - public async getPaths( - filters?: FileFilter[], - properties?: OpenDialogOptions["properties"] - ): Promise> { - try { - const result = await dialog.showOpenDialog({ filters, properties }) - return Result.success(result.filePaths) - } catch (error) { - return Result.failed( - new AppError( - DialogFileSystemError.GetPath, - error ? (error as Error).message : "Something went wrong" - ) - ) - } - } -} diff --git a/packages/app/src/file-system/services/index.ts b/packages/app/src/file-system/services/index.ts deleted file mode 100644 index 5ccdd60437..0000000000 --- a/packages/app/src/file-system/services/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Copyright (c) Mudita sp. z o.o. All rights reserved. - * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md - */ - -export * from "./file-system-dialog.service" diff --git a/packages/app/src/files-manager/actions/upload-file.action.test.ts b/packages/app/src/files-manager/actions/upload-file.action.test.ts index 2b923b6213..7383f8f849 100644 --- a/packages/app/src/files-manager/actions/upload-file.action.test.ts +++ b/packages/app/src/files-manager/actions/upload-file.action.test.ts @@ -22,7 +22,6 @@ import { } from "App/files-manager/actions/base.action" import { getFiles } from "App/files-manager/actions/get-files.action" -jest.mock("App/file-system/requests") jest.mock("App/files-manager/requests") const GET_FILES_MOCK_RESULT = { diff --git a/packages/app/src/files-manager/constants/controller.constant.ts b/packages/app/src/files-manager/constants/controller.constant.ts index 6b458b647b..cebf1315df 100644 --- a/packages/app/src/files-manager/constants/controller.constant.ts +++ b/packages/app/src/files-manager/constants/controller.constant.ts @@ -3,16 +3,8 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "files-manager" - export enum IpcFilesManagerEvent { - GetFiles = "get-files", - UploadFiles = "upload-files", - DeleteFiles = "delete-files", -} - -export enum IpcFilesManagerRequest { - GetFiles = "files-manager-get-files", - UploadFiles = "files-manager-upload-files", - DeleteFiles = "files-manager-delete-files", + GetFiles = "files-manager_get-files", + UploadFiles = "files-manager_upload-files", + DeleteFiles = "files-manager_delete-files", } diff --git a/packages/app/src/files-manager/controllers/files-manager.controller.ts b/packages/app/src/files-manager/controllers/files-manager.controller.ts index 9781a9a36c..c60613cafd 100644 --- a/packages/app/src/files-manager/controllers/files-manager.controller.ts +++ b/packages/app/src/files-manager/controllers/files-manager.controller.ts @@ -3,16 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" -import { - ControllerPrefix, - IpcFilesManagerEvent, -} from "App/files-manager/constants" +import { IpcFilesManagerEvent } from "App/files-manager/constants" import { File, UploadFilesInput, GetFilesInput } from "App/files-manager/dto" import { FileManagerService } from "App/files-manager/services" -@Controller(ControllerPrefix) export class FilesManagerController { constructor(private fileManagerService: FileManagerService) {} diff --git a/packages/app/src/files-manager/requests/delete-files.request.ts b/packages/app/src/files-manager/requests/delete-files.request.ts index d1c7f5bb9d..1dec12960a 100644 --- a/packages/app/src/files-manager/requests/delete-files.request.ts +++ b/packages/app/src/files-manager/requests/delete-files.request.ts @@ -5,10 +5,10 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcFilesManagerRequest } from "App/files-manager/constants" +import { IpcFilesManagerEvent } from "App/files-manager/constants" export const deleteFilesRequest = async ( paths: string[] ): Promise> => { - return ipcRenderer.callMain(IpcFilesManagerRequest.DeleteFiles, paths) + return ipcRenderer.callMain(IpcFilesManagerEvent.DeleteFiles, paths) } diff --git a/packages/app/src/files-manager/requests/get-files.request.ts b/packages/app/src/files-manager/requests/get-files.request.ts index 5420ff92aa..bb01db47b5 100644 --- a/packages/app/src/files-manager/requests/get-files.request.ts +++ b/packages/app/src/files-manager/requests/get-files.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcFilesManagerRequest } from "App/files-manager/constants" +import { IpcFilesManagerEvent } from "App/files-manager/constants" import { File, GetFilesInput } from "App/files-manager/dto" export const getFilesRequest = async ( input: GetFilesInput ): Promise> => { - return ipcRenderer.callMain(IpcFilesManagerRequest.GetFiles, input) + return ipcRenderer.callMain(IpcFilesManagerEvent.GetFiles, input) } diff --git a/packages/app/src/files-manager/requests/upload-files.request.ts b/packages/app/src/files-manager/requests/upload-files.request.ts index ad8c53993f..4d691df3be 100644 --- a/packages/app/src/files-manager/requests/upload-files.request.ts +++ b/packages/app/src/files-manager/requests/upload-files.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcFilesManagerRequest } from "App/files-manager/constants" +import { IpcFilesManagerEvent } from "App/files-manager/constants" import { UploadFilesInput } from "App/files-manager/dto" export const uploadFilesRequest = async ( input: UploadFilesInput ): Promise> => { - return ipcRenderer.callMain(IpcFilesManagerRequest.UploadFiles, input) + return ipcRenderer.callMain(IpcFilesManagerEvent.UploadFiles, input) } diff --git a/packages/app/src/messages/constants/controller.constant.ts b/packages/app/src/messages/constants/controller.constant.ts index a070943f1a..a2950e5cac 100644 --- a/packages/app/src/messages/constants/controller.constant.ts +++ b/packages/app/src/messages/constants/controller.constant.ts @@ -3,30 +3,14 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const MessageControllerPrefix = "message" - export enum IpcMessageEvent { - CreateMessage = "create-message", - DeleteMessage = "delete-message", - ResendMessage = "resend-message", - UpdateMessage = "update-message", -} - -export enum IpcMessageRequest { - CreateMessage = "message-create-message", - DeleteMessage = "message-delete-message", - ResendMessage = "message-resend-message", - UpdateMessage = "message-update-message", + CreateMessage = "message_create-message", + DeleteMessage = "message_delete-message", + ResendMessage = "message_resend-message", + UpdateMessage = "message_update-message", } -export const ThreadControllerPrefix = "thread" - export enum IpcThreadEvent { - DeleteThreads = "delete-threads", - ToggleThreadsReadStatus = "toggle-threads-read-status", -} - -export enum IpcThreadRequest { - DeleteThreads = "thread-delete-threads", - ToggleThreadsReadStatus = "thread-toggle-threads-read-status", + DeleteThreads = "thread_delete-threads", + ToggleThreadsReadStatus = "thread_toggle-threads-read-status", } diff --git a/packages/app/src/messages/controllers/message.controller.ts b/packages/app/src/messages/controllers/message.controller.ts index fc344c2aeb..8fca00efe3 100644 --- a/packages/app/src/messages/controllers/message.controller.ts +++ b/packages/app/src/messages/controllers/message.controller.ts @@ -4,19 +4,15 @@ */ import { ResultObject } from "App/core/builder" -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { RequestResponse } from "App/core/types/request-response.interface" import { CreateMessageDataResponse, MessageService, } from "App/messages/services" -import { - IpcMessageEvent, - MessageControllerPrefix, -} from "App/messages/constants/controller.constant" +import { IpcMessageEvent } from "App/messages/constants/controller.constant" import { NewMessage, Message } from "App/messages/dto" -@Controller(MessageControllerPrefix) export class MessageController { constructor(private messageService: MessageService) {} diff --git a/packages/app/src/messages/controllers/thread.controller.ts b/packages/app/src/messages/controllers/thread.controller.ts index a6ca197585..72ae7dd549 100644 --- a/packages/app/src/messages/controllers/thread.controller.ts +++ b/packages/app/src/messages/controllers/thread.controller.ts @@ -3,16 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { RequestResponse } from "App/core/types/request-response.interface" import { ThreadService } from "App/messages/services" -import { - IpcThreadEvent, - ThreadControllerPrefix, -} from "App/messages/constants/controller.constant" +import { IpcThreadEvent } from "App/messages/constants/controller.constant" import { Thread } from "App/messages/dto" -@Controller(ThreadControllerPrefix) export class ThreadController { constructor(private threadService: ThreadService) {} diff --git a/packages/app/src/messages/requests/create-message.request.ts b/packages/app/src/messages/requests/create-message.request.ts index e68db357a9..31f4ec4ad1 100644 --- a/packages/app/src/messages/requests/create-message.request.ts +++ b/packages/app/src/messages/requests/create-message.request.ts @@ -4,7 +4,7 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcMessageRequest } from "App/messages/constants/controller.constant" +import { IpcMessageEvent } from "App/messages/constants/controller.constant" import { NewMessage } from "App/messages/dto" import { RequestResponse } from "App/core/types/request-response.interface" import { CreateMessageDataResponse } from "App/messages/services" @@ -12,5 +12,5 @@ import { CreateMessageDataResponse } from "App/messages/services" export const createMessageRequest = ( newMessage: NewMessage ): Promise> => { - return ipcRenderer.callMain(IpcMessageRequest.CreateMessage, newMessage) + return ipcRenderer.callMain(IpcMessageEvent.CreateMessage, newMessage) } diff --git a/packages/app/src/messages/requests/delete-message.request.ts b/packages/app/src/messages/requests/delete-message.request.ts index adc0a2e370..0aa87d8e49 100644 --- a/packages/app/src/messages/requests/delete-message.request.ts +++ b/packages/app/src/messages/requests/delete-message.request.ts @@ -4,11 +4,11 @@ */ import { RequestResponse } from "App/core/types/request-response.interface" -import { IpcMessageRequest } from "App/messages/constants/controller.constant" +import { IpcMessageEvent } from "App/messages/constants/controller.constant" import { ipcRenderer } from "electron-better-ipc" export const deleteMessageRequest = ( messageId: string ): Promise> => { - return ipcRenderer.callMain(IpcMessageRequest.DeleteMessage, messageId) + return ipcRenderer.callMain(IpcMessageEvent.DeleteMessage, messageId) } diff --git a/packages/app/src/messages/requests/delete-threads.request.ts b/packages/app/src/messages/requests/delete-threads.request.ts index 0d3acfe56f..ca14e771b5 100644 --- a/packages/app/src/messages/requests/delete-threads.request.ts +++ b/packages/app/src/messages/requests/delete-threads.request.ts @@ -4,11 +4,11 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcThreadRequest } from "App/messages/constants/controller.constant" +import { IpcThreadEvent } from "App/messages/constants/controller.constant" import { RequestResponse } from "App/core/types/request-response.interface" export const deleteThreadsRequest = async ( threadIds: string[] ): Promise> => { - return await ipcRenderer.callMain(IpcThreadRequest.DeleteThreads, threadIds) + return await ipcRenderer.callMain(IpcThreadEvent.DeleteThreads, threadIds) } diff --git a/packages/app/src/messages/requests/resend-message.request.ts b/packages/app/src/messages/requests/resend-message.request.ts index 38abf20a2f..fedfcf650d 100644 --- a/packages/app/src/messages/requests/resend-message.request.ts +++ b/packages/app/src/messages/requests/resend-message.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { RequestResponse } from "App/core/types/request-response.interface" -import { IpcMessageRequest } from "App/messages/constants/controller.constant" +import { IpcMessageEvent } from "App/messages/constants/controller.constant" import { CreateMessageDataResponse } from "App/messages/services" export const resendMessageRequest = ( messageId: string ): Promise> => { - return ipcRenderer.callMain(IpcMessageRequest.ResendMessage, messageId) + return ipcRenderer.callMain(IpcMessageEvent.ResendMessage, messageId) } diff --git a/packages/app/src/messages/requests/toggle-threads-read-status.request.ts b/packages/app/src/messages/requests/toggle-threads-read-status.request.ts index 3681c9e2db..b13633ae83 100644 --- a/packages/app/src/messages/requests/toggle-threads-read-status.request.ts +++ b/packages/app/src/messages/requests/toggle-threads-read-status.request.ts @@ -4,7 +4,7 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcThreadRequest } from "App/messages/constants/controller.constant" +import { IpcThreadEvent } from "App/messages/constants/controller.constant" import { RequestResponse } from "App/core/types/request-response.interface" import { Thread } from "App/messages/dto" @@ -12,7 +12,7 @@ export const toggleThreadsReadStatusRequest = async ( threads: Thread[] ): Promise> => { return await ipcRenderer.callMain( - IpcThreadRequest.ToggleThreadsReadStatus, + IpcThreadEvent.ToggleThreadsReadStatus, threads ) } diff --git a/packages/app/src/messages/requests/update-message.request.ts b/packages/app/src/messages/requests/update-message.request.ts index 97942b9f08..98a9a33ec7 100644 --- a/packages/app/src/messages/requests/update-message.request.ts +++ b/packages/app/src/messages/requests/update-message.request.ts @@ -5,11 +5,11 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcMessageRequest } from "App/messages/constants/controller.constant" +import { IpcMessageEvent } from "App/messages/constants/controller.constant" import { Message } from "App/messages/dto" export const updateMessageRequest = ( message: Message ): Promise> => { - return ipcRenderer.callMain(IpcMessageRequest.UpdateMessage, message) + return ipcRenderer.callMain(IpcMessageEvent.UpdateMessage, message) } diff --git a/packages/app/src/search/constants/controller.constant.ts b/packages/app/src/search/constants/controller.constant.ts index 9d7541d840..c748490139 100644 --- a/packages/app/src/search/constants/controller.constant.ts +++ b/packages/app/src/search/constants/controller.constant.ts @@ -3,12 +3,6 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const SearchControllerPrefix = "search" - export enum IpcSearchEvent { - SearchData = "search-data", -} - -export enum IpcSearchRequest { - SearchData = "search-search-data", + SearchData = "search_search-data", } diff --git a/packages/app/src/search/controllers/search.controller.ts b/packages/app/src/search/controllers/search.controller.ts index 20828afdaf..a58e4832ee 100644 --- a/packages/app/src/search/controllers/search.controller.ts +++ b/packages/app/src/search/controllers/search.controller.ts @@ -3,13 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" -import { SearchControllerPrefix, IpcSearchEvent } from "App/search/constants" +import { IpcSearchEvent } from "App/search/constants" import { SearchParams, SearchResult } from "App/search/dto" import { SearchService } from "App/search/services" -@Controller(SearchControllerPrefix) export class SearchController { constructor(private searchService: SearchService) {} diff --git a/packages/app/src/search/requests/search.request.ts b/packages/app/src/search/requests/search.request.ts index 6063cd5f52..790f30f2e5 100644 --- a/packages/app/src/search/requests/search.request.ts +++ b/packages/app/src/search/requests/search.request.ts @@ -6,10 +6,10 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" import { SearchParams, SearchResult } from "App/search/dto" -import { IpcSearchRequest } from "App/search/constants" +import { IpcSearchEvent } from "App/search/constants" export const searchRequest = async ( data: SearchParams ): Promise> => { - return ipcRenderer.callMain(IpcSearchRequest.SearchData, data) + return ipcRenderer.callMain(IpcSearchEvent.SearchData, data) } diff --git a/packages/app/src/settings/constants/controller.constant.ts b/packages/app/src/settings/constants/controller.constant.ts index 458a0662f1..a0d12006fc 100644 --- a/packages/app/src/settings/constants/controller.constant.ts +++ b/packages/app/src/settings/constants/controller.constant.ts @@ -3,25 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const SettingsControllerPrefix = "settings" -export const ConfigurationsControllerPrefix = "configurations" - export enum IpcSettingsEvent { - Get = "get", - Reset = "reset", - Update = "update", + Get = "settings_get", + Reset = "settings_reset", + Update = "settings_update", } export enum IpcConfigurationsEvent { - Get = "get", -} - -export enum IpcSettingsRequest { - Get = "settings-get", - Reset = "settings-reset", - Update = "settings-update", -} - -export enum IpcConfigurationsRequest { - Get = "configurations-get", + Get = "configurations_get", } diff --git a/packages/app/src/settings/controllers/configuration.controller.ts b/packages/app/src/settings/controllers/configuration.controller.ts index 26aafe8e7e..0fb09c6977 100644 --- a/packages/app/src/settings/controllers/configuration.controller.ts +++ b/packages/app/src/settings/controllers/configuration.controller.ts @@ -3,15 +3,11 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" -import { - ConfigurationsControllerPrefix, - IpcConfigurationsEvent, -} from "App/settings/constants" +import { IpcEvent } from "App/core/decorators" +import { IpcConfigurationsEvent } from "App/settings/constants" import { Configuration } from "App/settings/dto" import { ConfigurationService } from "App/settings/services" -@Controller(ConfigurationsControllerPrefix) export class ConfigurationController { constructor(private configurationService: ConfigurationService) {} diff --git a/packages/app/src/settings/controllers/settings.controller.ts b/packages/app/src/settings/controllers/settings.controller.ts index 4ff18eb5b3..0c7595dfc1 100644 --- a/packages/app/src/settings/controllers/settings.controller.ts +++ b/packages/app/src/settings/controllers/settings.controller.ts @@ -3,16 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" -import { - SettingsControllerPrefix, - IpcSettingsEvent, -} from "App/settings/constants" +import { IpcEvent } from "App/core/decorators" +import { IpcSettingsEvent } from "App/settings/constants" import { Settings, SettingsUpdateOption } from "App/settings/dto" import { SettingsService } from "App/settings/services" import { SettingsValue } from "App/settings/types" -@Controller(SettingsControllerPrefix) export class SettingsController { constructor(private settingsService: SettingsService) {} diff --git a/packages/app/src/settings/requests/get-configuration.request.ts b/packages/app/src/settings/requests/get-configuration.request.ts index 68e39d44c2..83c9bea06d 100644 --- a/packages/app/src/settings/requests/get-configuration.request.ts +++ b/packages/app/src/settings/requests/get-configuration.request.ts @@ -5,7 +5,7 @@ import { ipcRenderer } from "electron-better-ipc" import { Configuration } from "App/settings/dto" -import { IpcConfigurationsRequest } from "App/settings/constants" +import { IpcConfigurationsEvent } from "App/settings/constants" export const getConfiguration = (): Promise => - ipcRenderer.callMain(IpcConfigurationsRequest.Get) + ipcRenderer.callMain(IpcConfigurationsEvent.Get) diff --git a/packages/app/src/settings/requests/get-settings.request.ts b/packages/app/src/settings/requests/get-settings.request.ts index c739a9dc45..cd239e3f34 100644 --- a/packages/app/src/settings/requests/get-settings.request.ts +++ b/packages/app/src/settings/requests/get-settings.request.ts @@ -5,7 +5,7 @@ import { ipcRenderer } from "electron-better-ipc" import { Settings } from "App/settings/dto" -import { IpcSettingsRequest } from "App/settings/constants" +import { IpcSettingsEvent } from "App/settings/constants" export const getSettings = (): Promise => - ipcRenderer.callMain(IpcSettingsRequest.Get) + ipcRenderer.callMain(IpcSettingsEvent.Get) diff --git a/packages/app/src/settings/requests/reset-settings.request.ts b/packages/app/src/settings/requests/reset-settings.request.ts index 6b67b35fbd..6ac9823a9d 100644 --- a/packages/app/src/settings/requests/reset-settings.request.ts +++ b/packages/app/src/settings/requests/reset-settings.request.ts @@ -5,7 +5,7 @@ import { ipcRenderer } from "electron-better-ipc" import { Settings } from "App/settings/dto" -import { IpcSettingsRequest } from "App/settings/constants" +import { IpcSettingsEvent } from "App/settings/constants" export const resetSettings = (): Promise => - ipcRenderer.callMain(IpcSettingsRequest.Reset) + ipcRenderer.callMain(IpcSettingsEvent.Reset) diff --git a/packages/app/src/settings/requests/update-settings.request.ts b/packages/app/src/settings/requests/update-settings.request.ts index 93a9763353..f317f66fa4 100644 --- a/packages/app/src/settings/requests/update-settings.request.ts +++ b/packages/app/src/settings/requests/update-settings.request.ts @@ -5,9 +5,9 @@ import { ipcRenderer } from "electron-better-ipc" import { Settings, SettingsUpdateOption } from "App/settings/dto" -import { IpcSettingsRequest } from "App/settings/constants" +import { IpcSettingsEvent } from "App/settings/constants" export const updateSettings = ( option: SettingsUpdateOption ): Promise> => - ipcRenderer.callMain(IpcSettingsRequest.Update, option) + ipcRenderer.callMain(IpcSettingsEvent.Update, option) diff --git a/packages/app/src/templates/constants/controller.constant.ts b/packages/app/src/templates/constants/controller.constant.ts index 8db7182127..1c6f43184e 100644 --- a/packages/app/src/templates/constants/controller.constant.ts +++ b/packages/app/src/templates/constants/controller.constant.ts @@ -3,18 +3,9 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const ControllerPrefix = "template" - export enum IpcTemplateEvent { - CreateTemplate = "create-template", - DeleteTemplates = "delete-templates", - UpdateTemplate = "update-template", - UpdateTemplateOrder = "update-template-order", -} - -export enum IpcTemplateRequest { - CreateTemplate = "template-create-template", - DeleteTemplates = "template-delete-templates", - UpdateTemplate = "template-update-template", - UpdateTemplateOrder = "template-update-template-order", + CreateTemplate = "template_create-template", + DeleteTemplates = "template_delete-templates", + UpdateTemplate = "template_update-template", + UpdateTemplateOrder = "template_update-template-order", } diff --git a/packages/app/src/templates/controllers/template.controller.ts b/packages/app/src/templates/controllers/template.controller.ts index 487573c60b..29c4ed91e5 100644 --- a/packages/app/src/templates/controllers/template.controller.ts +++ b/packages/app/src/templates/controllers/template.controller.ts @@ -3,13 +3,12 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { TemplateService } from "App/templates/services" import { RequestResponse } from "App/core/types/request-response.interface" -import { ControllerPrefix, IpcTemplateEvent } from "App/templates/constants" +import { IpcTemplateEvent } from "App/templates/constants" import { NewTemplate, Template } from "App/templates/dto" -@Controller(ControllerPrefix) export class TemplateController { constructor(private templateService: TemplateService) {} diff --git a/packages/app/src/templates/requests/create-template.request.ts b/packages/app/src/templates/requests/create-template.request.ts index 507b9ea864..19c5566894 100644 --- a/packages/app/src/templates/requests/create-template.request.ts +++ b/packages/app/src/templates/requests/create-template.request.ts @@ -4,12 +4,12 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcTemplateRequest } from "App/templates/constants" +import { IpcTemplateEvent } from "App/templates/constants" import { Template, NewTemplate } from "App/templates/dto" import { RequestResponse } from "App/core/types/request-response.interface" export const createTemplateRequest = async ( template: NewTemplate ): Promise> => { - return ipcRenderer.callMain(IpcTemplateRequest.CreateTemplate, template) + return ipcRenderer.callMain(IpcTemplateEvent.CreateTemplate, template) } diff --git a/packages/app/src/templates/requests/delete-templates.request.ts b/packages/app/src/templates/requests/delete-templates.request.ts index 140d6c5777..a5bb49bb03 100644 --- a/packages/app/src/templates/requests/delete-templates.request.ts +++ b/packages/app/src/templates/requests/delete-templates.request.ts @@ -4,14 +4,14 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcTemplateRequest } from "App/templates/constants" +import { IpcTemplateEvent } from "App/templates/constants" import { DeleteTemplateRequestResponse } from "App/templates/reducers" export const deleteTemplatesRequest = async ( templateIds: string[] ): Promise => { return await ipcRenderer.callMain( - IpcTemplateRequest.DeleteTemplates, + IpcTemplateEvent.DeleteTemplates, templateIds ) } diff --git a/packages/app/src/templates/requests/update-template-order.request.ts b/packages/app/src/templates/requests/update-template-order.request.ts index 3e8a9d323d..0e8d048ca3 100644 --- a/packages/app/src/templates/requests/update-template-order.request.ts +++ b/packages/app/src/templates/requests/update-template-order.request.ts @@ -4,7 +4,7 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcTemplateRequest } from "App/templates/constants" +import { IpcTemplateEvent } from "App/templates/constants" import { Template } from "App/templates/dto" import { UpdateTemplateOrderRequestResponse } from "App/templates/reducers" @@ -12,7 +12,7 @@ export const updateTemplateOrderRequest = async ( templates: Template[] ): Promise => { return await ipcRenderer.callMain( - IpcTemplateRequest.UpdateTemplateOrder, + IpcTemplateEvent.UpdateTemplateOrder, templates ) } diff --git a/packages/app/src/templates/requests/update-template.request.ts b/packages/app/src/templates/requests/update-template.request.ts index 2b877d3922..070924a56b 100644 --- a/packages/app/src/templates/requests/update-template.request.ts +++ b/packages/app/src/templates/requests/update-template.request.ts @@ -4,12 +4,12 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcTemplateRequest } from "App/templates/constants" +import { IpcTemplateEvent } from "App/templates/constants" import { Template } from "App/templates/dto" import { RequestResponse } from "App/core/types/request-response.interface" export const updateTemplateRequest = async ( template: Template ): Promise> => { - return ipcRenderer.callMain(IpcTemplateRequest.UpdateTemplate, template) + return ipcRenderer.callMain(IpcTemplateEvent.UpdateTemplate, template) } diff --git a/packages/app/src/update/constants/controller.constant.ts b/packages/app/src/update/constants/controller.constant.ts index 6dde15df48..7714a8a820 100644 --- a/packages/app/src/update/constants/controller.constant.ts +++ b/packages/app/src/update/constants/controller.constant.ts @@ -3,29 +3,14 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -export const DeviceUpdateControllerPrefix = "device-update" -export const ReleaseControllerPrefix = "release" - export enum IpcReleaseEvent { - GetAllReleases = "get-all-releases", - GetLatestRelease = "get-latest-release", - GetReleasesByVersions = "get-releases-by-versions", -} - -export enum IpcReleaseRequest { - GetAllReleases = "release-get-all-releases", - GetLatestRelease = "release-get-latest-release", - GetReleasesByVersions = "release-get-releases-by-versions", + GetAllReleases = "os-release_get-all-releases", + GetLatestRelease = "os-release_get-latest-release", + GetReleasesByVersions = "os-release_get-releases-by-versions", } export enum IpcDeviceUpdateEvent { - UpdateOS = "update-os", - CheckUpdate = "check-update", - RemoveDownloadedOsUpdates = "remove-downloaded-os-updates", -} - -export enum IpcDeviceUpdateRequest { - UpdateOS = "device-update-update-os", - CheckUpdate = "device-update-check-update", - RemoveDownloadedOsUpdates = "device-update-remove-downloaded-os-updates", + UpdateOS = "device-update_update-os", + CheckUpdate = "device-update_check-update", + RemoveDownloadedOsUpdates = "device-update_remove-downloaded-os-updates", } diff --git a/packages/app/src/update/controllers/device-update.controller.ts b/packages/app/src/update/controllers/device-update.controller.ts index 6490ee3c91..cce367f2fd 100644 --- a/packages/app/src/update/controllers/device-update.controller.ts +++ b/packages/app/src/update/controllers/device-update.controller.ts @@ -3,19 +3,15 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { ResultObject } from "App/core/builder" import { UpdateOS } from "App/update/dto" import { DeviceUpdateFilesService, DeviceUpdateService, } from "App/update/services" -import { - DeviceUpdateControllerPrefix, - IpcDeviceUpdateEvent, -} from "App/update/constants" +import { IpcDeviceUpdateEvent } from "App/update/constants" -@Controller(DeviceUpdateControllerPrefix) export class DeviceUpdateController { constructor( private deviceUpdateService: DeviceUpdateService, diff --git a/packages/app/src/update/controllers/releases.controller.ts b/packages/app/src/update/controllers/releases.controller.ts index 83015f2575..b5b395f3db 100644 --- a/packages/app/src/update/controllers/releases.controller.ts +++ b/packages/app/src/update/controllers/releases.controller.ts @@ -3,18 +3,13 @@ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md */ -import { Controller, IpcEvent } from "App/core/decorators" +import { IpcEvent } from "App/core/decorators" import { Feature, flags } from "App/feature-flags" import { ResultObject, Result } from "App/core/builder" -import { - ReleaseControllerPrefix, - IpcReleaseEvent, - Product, -} from "App/update/constants" +import { IpcReleaseEvent, Product } from "App/update/constants" import { GetReleasesByVersionsInput, OsRelease } from "App/update/dto" import { ReleaseService } from "App/update/services" -@Controller(ReleaseControllerPrefix) export class ReleasesController { constructor(private releaseService: ReleaseService) {} diff --git a/packages/app/src/update/requests/checkUpdate.request.ts b/packages/app/src/update/requests/checkUpdate.request.ts index 9547b38b4a..0f3d62dbb6 100644 --- a/packages/app/src/update/requests/checkUpdate.request.ts +++ b/packages/app/src/update/requests/checkUpdate.request.ts @@ -6,12 +6,12 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" import { - IpcDeviceUpdateRequest, UpdateErrorServiceErrors, + IpcDeviceUpdateEvent, } from "App/update/constants" export const checkUpdate = async (): Promise< ResultObject > => { - return ipcRenderer.callMain(IpcDeviceUpdateRequest.CheckUpdate) + return ipcRenderer.callMain(IpcDeviceUpdateEvent.CheckUpdate) } diff --git a/packages/app/src/update/requests/get-all-releases.request.ts b/packages/app/src/update/requests/get-all-releases.request.ts index 4811021dc0..f3df6c18a0 100644 --- a/packages/app/src/update/requests/get-all-releases.request.ts +++ b/packages/app/src/update/requests/get-all-releases.request.ts @@ -5,14 +5,14 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcReleaseRequest, Product } from "App/update/constants" +import { IpcReleaseEvent, Product } from "App/update/constants" import { OsRelease } from "App/update/dto" export const getAllReleasesRequest = async ( product: Product, deviceSerialNumber?: string ): Promise> => { - return ipcRenderer.callMain(IpcReleaseRequest.GetAllReleases, { + return ipcRenderer.callMain(IpcReleaseEvent.GetAllReleases, { product, deviceSerialNumber, }) diff --git a/packages/app/src/update/requests/get-latest-release.request.ts b/packages/app/src/update/requests/get-latest-release.request.ts index 3101ccb11f..2dff2e0d9d 100644 --- a/packages/app/src/update/requests/get-latest-release.request.ts +++ b/packages/app/src/update/requests/get-latest-release.request.ts @@ -5,14 +5,14 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" -import { IpcReleaseRequest, Product } from "App/update/constants" +import { IpcReleaseEvent, Product } from "App/update/constants" import { OsRelease } from "App/update/dto" export const getLatestReleaseRequest = async ( product: Product, deviceSerialNumber?: string ): Promise> => { - return ipcRenderer.callMain(IpcReleaseRequest.GetLatestRelease, { + return ipcRenderer.callMain(IpcReleaseEvent.GetLatestRelease, { product, deviceSerialNumber, }) diff --git a/packages/app/src/update/requests/get-releases-by-versions.request.ts b/packages/app/src/update/requests/get-releases-by-versions.request.ts index 5e5bad8160..fec99efb86 100644 --- a/packages/app/src/update/requests/get-releases-by-versions.request.ts +++ b/packages/app/src/update/requests/get-releases-by-versions.request.ts @@ -4,12 +4,12 @@ */ import { ResultObject } from "App/core/builder" -import { IpcReleaseRequest } from "App/update/constants" +import { IpcReleaseEvent } from "App/update/constants" import { GetReleasesByVersionsInput, OsRelease } from "App/update/dto" import { ipcRenderer } from "electron-better-ipc" export const getReleasesByVersions = async ( params: GetReleasesByVersionsInput ): Promise> => { - return ipcRenderer.callMain(IpcReleaseRequest.GetReleasesByVersions, params) + return ipcRenderer.callMain(IpcReleaseEvent.GetReleasesByVersions, params) } diff --git a/packages/app/src/update/requests/remove-downloaded-os-updates.request.ts b/packages/app/src/update/requests/remove-downloaded-os-updates.request.ts index 975853dd4b..5780d02c5a 100644 --- a/packages/app/src/update/requests/remove-downloaded-os-updates.request.ts +++ b/packages/app/src/update/requests/remove-downloaded-os-updates.request.ts @@ -4,8 +4,8 @@ */ import { ipcRenderer } from "electron-better-ipc" -import { IpcDeviceUpdateRequest } from "App/update/constants" +import { IpcDeviceUpdateEvent } from "App/update/constants" export const removeDownloadedOsUpdates = (): Promise => { - return ipcRenderer.callMain(IpcDeviceUpdateRequest.RemoveDownloadedOsUpdates) + return ipcRenderer.callMain(IpcDeviceUpdateEvent.RemoveDownloadedOsUpdates) } diff --git a/packages/app/src/update/requests/start-os-update.request.ts b/packages/app/src/update/requests/start-os-update.request.ts index 69a2edf07e..1b3ae4a996 100644 --- a/packages/app/src/update/requests/start-os-update.request.ts +++ b/packages/app/src/update/requests/start-os-update.request.ts @@ -6,7 +6,7 @@ import { ipcRenderer } from "electron-better-ipc" import { ResultObject } from "App/core/builder" import { - IpcDeviceUpdateRequest, + IpcDeviceUpdateEvent, UpdateErrorServiceErrors, } from "App/update/constants" import { UpdateOS } from "App/update/dto" @@ -14,5 +14,5 @@ import { UpdateOS } from "App/update/dto" export const startOsUpdate = async ( payload: UpdateOS ): Promise> => { - return ipcRenderer.callMain(IpcDeviceUpdateRequest.UpdateOS, payload) + return ipcRenderer.callMain(IpcDeviceUpdateEvent.UpdateOS, payload) }