chore: update cloudly dependency stack

Align Cloudly with the current typedserver, smartconfig, smartstate, and Docker tooling releases so builds and Docker output stay compatible with the upgraded stack.
This commit is contained in:
2026-05-08 13:56:20 +00:00
parent 80226c8a1c
commit f40ef6b7c0
75 changed files with 4003 additions and 6406 deletions
+36 -42
View File
@@ -305,15 +305,14 @@ export class CloudlyBaseOsManager {
}
public async handleRegisterHttpRequest(
reqArg: plugins.typedserver.Request,
resArg: plugins.typedserver.Response,
) {
ctxArg: plugins.typedserver.IRequestContext,
): Promise<Response> {
try {
const requestData = await this.readJsonBody<IBaseOsRegisterRequest>(reqArg);
const requestData = await this.readJsonBody<IBaseOsRegisterRequest>(ctxArg);
const response = await this.registerNode(requestData);
this.sendJson(resArg, 200, response);
return this.createJsonResponse(200, response);
} catch (error) {
this.sendJson(resArg, 400, {
return this.createJsonResponse(400, {
accepted: false,
message: `BaseOS registration failed: ${(error as Error).message}`,
} satisfies IBaseOsRegisterResponse);
@@ -321,15 +320,14 @@ export class CloudlyBaseOsManager {
}
public async handleHeartbeatHttpRequest(
reqArg: plugins.typedserver.Request,
resArg: plugins.typedserver.Response,
) {
ctxArg: plugins.typedserver.IRequestContext,
): Promise<Response> {
try {
const requestData = await this.readJsonBody<IBaseOsHeartbeatRequest>(reqArg);
const requestData = await this.readJsonBody<IBaseOsHeartbeatRequest>(ctxArg);
const response = await this.acceptHeartbeat(requestData);
this.sendJson(resArg, 200, response);
return this.createJsonResponse(200, response);
} catch (error) {
this.sendJson(resArg, 400, {
return this.createJsonResponse(400, {
accepted: false,
message: `BaseOS heartbeat failed: ${(error as Error).message}`,
} satisfies IBaseOsHeartbeatResponse);
@@ -337,37 +335,35 @@ export class CloudlyBaseOsManager {
}
public async handleImageDownloadHttpRequest(
reqArg: plugins.typedserver.Request,
resArg: plugins.typedserver.Response,
) {
ctxArg: plugins.typedserver.IRequestContext,
): Promise<Response> {
try {
const requestUrl = new URL((reqArg as any).originalUrl || reqArg.url || '/', 'http://localhost');
const buildId = requestUrl.pathname.split('/').at(-2);
const token = requestUrl.searchParams.get('token');
const buildId = ctxArg.params.buildId || ctxArg.url.pathname.split('/').at(-2);
const token = ctxArg.url.searchParams.get('token');
if (!buildId || !token) {
this.sendJson(resArg, 400, { errorText: 'build id or download token missing' });
return;
return this.createJsonResponse(400, { errorText: 'build id or download token missing' });
}
const build = await this.getImageBuildById(buildId);
if (build.downloadTokenHash !== this.hashSecret(token) || (build.downloadTokenExpiresAt || 0) < Date.now()) {
this.sendJson(resArg, 403, { errorText: 'download token is invalid or expired' });
return;
return this.createJsonResponse(403, { errorText: 'download token is invalid or expired' });
}
if (build.data.status !== 'ready' || !build.data.artifact) {
this.sendJson(resArg, 409, { errorText: 'image build is not ready' });
return;
return this.createJsonResponse(409, { errorText: 'image build is not ready' });
}
const artifact = build.data.artifact;
const bucket = await this.getArtifactBucket(artifact.bucketName);
const artifactStream = await bucket.fastGetStream({ path: artifact.key }, 'nodestream');
resArg.status(200);
resArg.setHeader('Content-Type', artifact.contentType || 'application/octet-stream');
resArg.setHeader('Content-Length', String(artifact.size));
resArg.setHeader('Content-Disposition', `attachment; filename="${artifact.filename}"`);
(artifactStream as nodeStream.Readable).pipe(resArg as any);
return new Response(nodeStream.Readable.toWeb(artifactStream as nodeStream.Readable) as ReadableStream, {
status: 200,
headers: {
'Content-Type': artifact.contentType || 'application/octet-stream',
'Content-Length': String(artifact.size),
'Content-Disposition': `attachment; filename="${artifact.filename}"`,
},
});
} catch (error) {
this.sendJson(resArg, 500, {
return this.createJsonResponse(500, {
errorText: `BaseOS image download failed: ${(error as Error).message}`,
});
}
@@ -986,22 +982,20 @@ export class CloudlyBaseOsManager {
&& typeof runtimeInfo.checkedAt === 'number';
}
private async readJsonBody<T>(reqArg: plugins.typedserver.Request): Promise<T> {
const chunks: Buffer[] = [];
for await (const chunk of reqArg as any) {
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
}
const bodyString = Buffer.concat(chunks).toString('utf8').trim();
private async readJsonBody<T>(ctxArg: plugins.typedserver.IRequestContext): Promise<T> {
const bodyString = (await ctxArg.text()).trim();
return bodyString ? JSON.parse(bodyString) as T : {} as T;
}
private sendJson(
resArg: plugins.typedserver.Response,
private createJsonResponse(
statusCodeArg: number,
bodyArg: object,
) {
resArg.status(statusCodeArg);
resArg.setHeader('Content-Type', 'application/json');
resArg.end(JSON.stringify(bodyArg));
): Response {
return new Response(JSON.stringify(bodyArg), {
status: statusCodeArg,
headers: {
'Content-Type': 'application/json',
},
});
}
}