feat: add platform desired state manager
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { CloudlyPlatformManager } from './classes.platformmanager.js';
|
||||
|
||||
@plugins.smartdata.managed()
|
||||
export class PlatformProviderConfig extends plugins.smartdata.SmartDataDbDoc<
|
||||
PlatformProviderConfig,
|
||||
plugins.servezoneInterfaces.platform.IPlatformProviderConfig,
|
||||
CloudlyPlatformManager
|
||||
> {
|
||||
public static async upsertProviderConfig(
|
||||
providerConfigArg: plugins.servezoneInterfaces.platform.IPlatformProviderConfig,
|
||||
) {
|
||||
const providerConfig =
|
||||
(providerConfigArg.id &&
|
||||
(await this.getInstance({
|
||||
id: providerConfigArg.id,
|
||||
}))) || new PlatformProviderConfig();
|
||||
|
||||
Object.assign(providerConfig, {
|
||||
...providerConfigArg,
|
||||
id: providerConfigArg.id || (await this.getNewId()),
|
||||
});
|
||||
await providerConfig.save();
|
||||
return providerConfig;
|
||||
}
|
||||
|
||||
@plugins.smartdata.unI()
|
||||
public id!: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public capability!: plugins.servezoneInterfaces.platform.TPlatformCapability;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public providerType!: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public name!: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public enabled!: boolean;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public config?: { [key: string]: plugins.servezoneInterfaces.platform.TPlatformConfigValue };
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public secretBundleId?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user