feat(apps): Add Apps subsystem: App and AppConnection models, managers, typed request handlers, web UI routes and documentation
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { AppConnectionManager } from './classes.appconnectionmanager.js';
|
||||
|
||||
@plugins.smartdata.Manager()
|
||||
export class AppConnection extends plugins.smartdata.SmartDataDbDoc<
|
||||
AppConnection,
|
||||
plugins.idpInterfaces.data.IAppConnection,
|
||||
AppConnectionManager
|
||||
> {
|
||||
// INSTANCE
|
||||
@plugins.smartdata.unI()
|
||||
id: plugins.idpInterfaces.data.IAppConnection['id'];
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
data: plugins.idpInterfaces.data.IAppConnection['data'];
|
||||
|
||||
/**
|
||||
* Check if the connection is active
|
||||
*/
|
||||
public isActive(): boolean {
|
||||
return this.data.status === 'active';
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the app
|
||||
*/
|
||||
public async disconnect(): Promise<void> {
|
||||
this.data.status = 'disconnected';
|
||||
await this.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnect the app
|
||||
*/
|
||||
public async reconnect(userId: string): Promise<void> {
|
||||
this.data.status = 'active';
|
||||
this.data.connectedAt = Date.now();
|
||||
this.data.connectedByUserId = userId;
|
||||
await this.save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user