2026-04-28 12:18:12 +00:00
|
|
|
import * as plugins from '../plugins.js';
|
|
|
|
|
import type { CloudlyPlatformManager } from './classes.platformmanager.js';
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.managed()
|
|
|
|
|
export class PlatformBinding extends plugins.smartdata.SmartDataDbDoc<
|
|
|
|
|
PlatformBinding,
|
|
|
|
|
plugins.servezoneInterfaces.platform.IPlatformBinding,
|
|
|
|
|
CloudlyPlatformManager
|
|
|
|
|
> {
|
|
|
|
|
public static async upsertBinding(
|
|
|
|
|
bindingArg: plugins.servezoneInterfaces.platform.IPlatformBinding,
|
|
|
|
|
) {
|
2026-05-08 13:56:20 +00:00
|
|
|
const existingBinding = bindingArg.id
|
|
|
|
|
? await this.getInstance({
|
2026-04-28 12:18:12 +00:00
|
|
|
id: bindingArg.id,
|
2026-05-08 13:56:20 +00:00
|
|
|
})
|
|
|
|
|
: undefined;
|
2026-04-28 12:18:12 +00:00
|
|
|
const binding = existingBinding || new PlatformBinding();
|
|
|
|
|
const timestamp = Date.now();
|
|
|
|
|
|
|
|
|
|
Object.assign(binding, {
|
|
|
|
|
...bindingArg,
|
|
|
|
|
id: bindingArg.id || (await this.getNewId()),
|
|
|
|
|
status: bindingArg.status || 'requested',
|
|
|
|
|
desiredState: bindingArg.desiredState || 'enabled',
|
|
|
|
|
createdAt: bindingArg.createdAt || existingBinding?.createdAt || timestamp,
|
|
|
|
|
updatedAt: timestamp,
|
|
|
|
|
});
|
|
|
|
|
await binding.save();
|
|
|
|
|
return binding;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.unI()
|
|
|
|
|
public id!: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public serviceId!: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public capability!: plugins.servezoneInterfaces.platform.TPlatformCapability;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public desiredState!: plugins.servezoneInterfaces.platform.TPlatformDesiredState;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public status!: plugins.servezoneInterfaces.platform.TPlatformBindingStatus;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public providerConfigId?: string;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public config?: { [key: string]: plugins.servezoneInterfaces.platform.TPlatformConfigValue };
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public endpoints?: plugins.servezoneInterfaces.platform.IPlatformServiceEndpoint[];
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public credentials?: plugins.servezoneInterfaces.platform.IPlatformCredentialRef[];
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public createdAt?: number;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public updatedAt?: number;
|
|
|
|
|
|
|
|
|
|
@plugins.smartdata.svDb()
|
|
|
|
|
public errorText?: string;
|
|
|
|
|
}
|