MPM marketplace and UI updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DatabaseService } from '../database/database.service';
|
||||
import type { ModuleManifest, ModuleRecord, ModuleStatus } from './manifest.types';
|
||||
import type { ModuleConfigurationField, ModuleManifest, ModuleRecord, ModuleStatus } from './manifest.types';
|
||||
|
||||
interface ModuleRow {
|
||||
id: string;
|
||||
@@ -19,11 +19,13 @@ interface ModuleRow {
|
||||
updated_at: Date;
|
||||
compose_file: string | null;
|
||||
app_service: string | null;
|
||||
configuration_schema: ModuleConfigurationField[];
|
||||
configuration_ready: boolean;
|
||||
}
|
||||
|
||||
const MODULE_COLUMNS = `id, module_id, name, slug, version, description, author, path,
|
||||
status, internal_port, healthcheck_url, enabled, created_at, updated_at,
|
||||
compose_file, app_service`;
|
||||
compose_file, app_service, configuration_schema, configuration_ready`;
|
||||
|
||||
/**
|
||||
* Modul-Repository (Infrastructure): Datenbankzugriffe für die Modul-Registry.
|
||||
@@ -84,8 +86,8 @@ export class ModuleRepository {
|
||||
const result = await this.database.query<ModuleRow>(
|
||||
`INSERT INTO modules
|
||||
(module_id, name, slug, version, description, author, path, status, internal_port, healthcheck_url,
|
||||
compose_file, app_service)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, 'INSTALLED', $8, $9, $10, $11)
|
||||
compose_file, app_service, configuration_schema, configuration_ready)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, 'INSTALLED', $8, $9, $10, $11, $12::jsonb, $13)
|
||||
RETURNING ${MODULE_COLUMNS}`,
|
||||
[
|
||||
manifest.id,
|
||||
@@ -99,6 +101,8 @@ export class ModuleRepository {
|
||||
manifest.healthcheck,
|
||||
manifest.composeFile ?? null,
|
||||
manifest.appService ?? null,
|
||||
JSON.stringify(manifest.configuration),
|
||||
manifest.configuration.every((field) => !field.required || field.defaultValue !== undefined),
|
||||
],
|
||||
);
|
||||
return this.mapRow(result.rows[0]);
|
||||
@@ -118,6 +122,18 @@ export class ModuleRepository {
|
||||
);
|
||||
}
|
||||
|
||||
async updateManifest(id: string, manifest: ModuleManifest, configurationReady: boolean): Promise<void> {
|
||||
await this.database.query(
|
||||
`UPDATE modules SET name = $2, version = $3, description = $4, author = $5,
|
||||
internal_port = $6, healthcheck_url = $7, compose_file = $8, app_service = $9,
|
||||
configuration_schema = $10::jsonb, configuration_ready = $11, updated_at = now()
|
||||
WHERE id = $1`,
|
||||
[id, manifest.name, manifest.version, manifest.description, manifest.author, manifest.port,
|
||||
manifest.healthcheck, manifest.composeFile ?? null, manifest.appService ?? null,
|
||||
JSON.stringify(manifest.configuration), configurationReady],
|
||||
);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<void> {
|
||||
await this.database.query('DELETE FROM modules WHERE id = $1', [id]);
|
||||
}
|
||||
@@ -140,6 +156,15 @@ export class ModuleRepository {
|
||||
updatedAt: row.updated_at,
|
||||
composeFile: row.compose_file,
|
||||
appService: row.app_service,
|
||||
configuration: row.configuration_schema,
|
||||
configurationReady: row.configuration_ready,
|
||||
};
|
||||
}
|
||||
|
||||
async updateConfigurationReady(id: string, ready: boolean): Promise<void> {
|
||||
await this.database.query(
|
||||
'UPDATE modules SET configuration_ready = $2, updated_at = now() WHERE id = $1',
|
||||
[id, ready],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user