fix(structure): improve structure, prepare better CI integration

This commit is contained in:
2024-06-05 14:13:03 +02:00
parent 2e6e7f6ca8
commit 55b2872ffc
8 changed files with 58 additions and 32 deletions

View File

@ -1,10 +1,10 @@
import * as plugins from './plugins.js';
export type TClientType = 'coreflow' | 'cli' | 'serverconfig';
export type TClientType = 'api' | 'ci' | 'coreflow' | 'cli' | 'serverconfig';
import { Image } from './classes.image.js';
export class CloudlyClient {
export class CloudlyApiClient {
private cloudlyUrl: string;
private registerAs: string;
@ -20,9 +20,13 @@ export class CloudlyClient {
plugins.servezoneInterfaces.requests.server.IRequest_TriggerServerAction['request']
>();
constructor(registerAsArg: TClientType) {
this.cloudlyUrl = process.env.CLOUDLY_URL || 'https://cloudly.layer.io:443';
this.registerAs = registerAsArg;
constructor(optionsArg?: {
registerAs: TClientType;
cloudlyUrl?: string;
}) {
this.registerAs = optionsArg.registerAs;
this.cloudlyUrl =
optionsArg?.cloudlyUrl || process.env.CLOUDLY_URL || 'https://cloudly.layer.io:443';
console.log(
`creating LoleCloudlyClient: registering as ${this.registerAs} and target url ${this.cloudlyUrl}`
@ -35,13 +39,6 @@ export class CloudlyClient {
})
);
this.typedrouter.addTypedHandler<plugins.servezoneInterfaces.requests.config.IRequest_Cloudly_Coreflow_PushClusterConfig>(
new plugins.typedrequest.TypedHandler('pushClusterConfig', async (dataArg) => {
this.configUpdateSubject.next(dataArg);
return {};
})
);
this.typedrouter.addTypedHandler<plugins.servezoneInterfaces.requests.server.IRequest_TriggerServerAction>(
new plugins.typedrequest.TypedHandler('triggerServerAction', async (dataArg) => {
this.serverActionSubject.next(dataArg);
@ -57,7 +54,9 @@ export class CloudlyClient {
this.typedrouter,
this.cloudlyUrl
);
console.log(`CloudlyCluent connected to cloudly at ${this.cloudlyUrl}. Remember to get an identity.`)
console.log(
`CloudlyCluent connected to cloudly at ${this.cloudlyUrl}. Remember to get an identity.`
);
}
public async stop() {
@ -115,7 +114,7 @@ export class CloudlyClient {
);
const response = await serverConfigRequest.fire({
jwt: '', // TODO: do proper auth here
serverId: '' // TODO: get server id here
serverId: '', // TODO: get server id here
});
return response.configData;
}
@ -125,7 +124,9 @@ export class CloudlyClient {
* @param serviceNameArg
* @param domainNameArg
*/
public async getCertificateForDomainOverHttps(domainNameArg: string): Promise<plugins.tsclass.network.ICert> {
public async getCertificateForDomainOverHttps(
domainNameArg: string
): Promise<plugins.tsclass.network.ICert> {
const typedCertificateRequest =
this.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.certificate.IRequest_Any_Cloudly_GetSslCertificate>(
'getSslCertificate'

View File

@ -1,8 +1,8 @@
import type { CloudlyClient } from './classes.cloudlyclient.js';
import type { CloudlyApiClient } from './classes.cloudlyapiclient.js';
import * as plugins from './plugins.js';
export class Image implements plugins.servezoneInterfaces.data.IImage {
public static async getImages(cloudlyClientRef: CloudlyClient) {
public static async getImages(cloudlyClientRef: CloudlyApiClient) {
const getAllImagesTR = cloudlyClientRef.typedsocketClient.createTypedRequest<plugins.servezoneInterfaces.requests.image.IRequest_GetAllImages>(
'getAllImages'
);
@ -19,12 +19,12 @@ export class Image implements plugins.servezoneInterfaces.data.IImage {
}
// INSTANCE
cloudlyClientRef: CloudlyClient;
cloudlyClientRef: CloudlyApiClient;
id: plugins.servezoneInterfaces.data.IImage['id'];
data: plugins.servezoneInterfaces.data.IImage['data'];
constructor(cloudlyClientRef: CloudlyClient) {
constructor(cloudlyClientRef: CloudlyApiClient) {
this.cloudlyClientRef = cloudlyClientRef;
}

View File

@ -1 +1 @@
export * from './classes.cloudlyclient.js';
export * from './classes.cloudlyapiclient.js';