Class: ImportDataCommand
Defined in: electron/services/commands/DatabaseCommands.ts:567
Command for importing application data from JSON.
Remarks
Encapsulates the logic for importing data, updating the cache, and emitting a
success event. Also emits a cache:invalidated event so renderer caches can
resynchronize with freshly imported data. Rollback restores the previous
cache state. Validation checks for non-empty JSON plus schema compliance via
the shared import/export Zod schemas.
Extends
DatabaseCommand<boolean>
Constructors
Constructor
new ImportDataCommand(
serviceFactory:DatabaseServiceFactory,eventEmitter:TypedEventBus<UptimeEvents>,cache:StandardizedCache<Site>,data:string):ImportDataCommand
Defined in: electron/services/commands/DatabaseCommands.ts:786
Parameters
serviceFactory
eventEmitter
cache
data
string
Returns
ImportDataCommand
Overrides
Constructor
new ImportDataCommand(
context:DatabaseCommandContext& {data:string; }):ImportDataCommand
Defined in: electron/services/commands/DatabaseCommands.ts:793
Parameters
context
DatabaseCommandContext & { data: string; }
Returns
ImportDataCommand
Overrides
Properties
cache
protectedreadonlycache:StandardizedCache<Site>
Defined in: electron/services/commands/DatabaseCommands.ts:189
Site cache for data synchronization during operations
Inherited from
eventEmitter
protectedreadonlyeventEmitter:TypedEventBus<UptimeEvents>
Defined in: electron/services/commands/DatabaseCommands.ts:192
Event bus for emitting command execution events
Inherited from
serviceFactory
protectedreadonlyserviceFactory:DatabaseServiceFactory
Defined in: electron/services/commands/DatabaseCommands.ts:195
Factory for accessing database services and repositories
Inherited from
DatabaseCommand.serviceFactory
configurationManager
protectedreadonlyconfigurationManager:ConfigurationManager|undefined
Defined in: electron/services/commands/DatabaseCommands.ts:198
Optional configuration manager used for validation flows
Inherited from
DatabaseCommand.configurationManager
updateHistoryLimit
protectedreadonlyupdateHistoryLimit: (limit:number) =>Promise<void> |undefined
Defined in: electron/services/commands/DatabaseCommands.ts:201
Optional history limit updater for settings propagation
Inherited from
DatabaseCommand.updateHistoryLimit
backupSites
privatebackupSites:Site[] =[]
Defined in: electron/services/commands/DatabaseCommands.ts:569
Backup of current sites for rollback functionality
data
privatereadonlydata:string
Defined in: electron/services/commands/DatabaseCommands.ts:572
JSON data string to be imported
Methods
emitFailureEvent()
protectedemitFailureEvent<K>(eventType:K,error:Error,data:Partial<UptimeEvents[K]>):Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:218
Internal
Emits a failure event for the command operation.
Type Parameters
K
K extends string
Parameters
eventType
K
The event type to emit.
error
The ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error that occurred.
data
Partial<UptimeEvents[K]> = {}
Additional event data to include in the event payload.
Returns
Promise<void>
Remarks
Used internally to emit a typed event indicating command failure, including error details and additional event data.
Inherited from
DatabaseCommand.emitFailureEvent
emitSuccessEvent()
protectedemitSuccessEvent<K>(eventType:K,data:Partial<UptimeEvents[K]>):Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:243
Internal
Emits a success event for the command operation.
Type Parameters
K
K extends string
Parameters
eventType
K
The event type to emit.
data
Partial<UptimeEvents[K]>
Additional event data to include in the event payload.
Returns
Promise<void>
Remarks
Used internally to emit a typed event indicating command success, including additional event data.
Inherited from
DatabaseCommand.emitSuccessEvent
execute()
execute():
Promise<boolean>
Defined in: electron/services/commands/DatabaseCommands.ts:574
Executes the command operation.
Returns
Promise<boolean>
Promise resolving to the operation result.
Remarks
Performs the main database operation encapsulated by the command.
Throws
When command execution fails.
Overrides
rollback()
rollback():
Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:646
Rolls back the command operation if possible.
Returns
Promise<void>
Promise resolving when rollback is complete.
Remarks
Attempts to revert the effects of the command. Not all commands require rollback.
Overrides
validate()
validate():
Promise<{errors:string[];isValid:boolean; }>
Defined in: electron/services/commands/DatabaseCommands.ts:655
Validates the command before execution.
Returns
Promise<{ errors: string[]; isValid: boolean; }>
Promise resolving to validation result.
Remarks
Ensures the command is in a valid state before execution. Returns a validation result with errors if any.
Overrides
applyImportedHistoryLimit()
privateapplyImportedHistoryLimit(settings:Record<string,string>):Promise<void>
Defined in: electron/services/commands/DatabaseCommands.ts:693
Parameters
settings
Record<string, string>
Returns
Promise<void>
validateImportedSites()
privatevalidateImportedSites(sites:ImportSite[]):Promise<Site[]>
Defined in: electron/services/commands/DatabaseCommands.ts:729
Parameters
sites
Returns
getDescription()
getDescription():
string
Defined in: electron/services/commands/DatabaseCommands.ts:823
Gets a description of the command for logging and debugging.
Returns
string
Human-readable command description.
Overrides
DatabaseCommand.getDescription
toCanonicalSite()
privatetoCanonicalSite(site:ImportSite):Site
Defined in: electron/services/commands/DatabaseCommands.ts:827