mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 06:36:38 +08:00
13d6966cb5
-transition `of_config_versions` primary key from `id` to `version` string. -add database migration files `202606270001_make_version_primary_key.sql` for PostgreSQL and SQLite. -introduce AfterFind/AfterCreate GORM hooks to preserve JSON backward compatibility. -refactor API controllers, logics, and front-end typescript definitions to receive `string` parameter.
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import type {InternalAxiosRequestConfig} from 'axios';
|
|
|
|
import {OpenFlareBaseService} from './base.service';
|
|
import type {
|
|
ConfigDiffResult,
|
|
ConfigPreviewResult,
|
|
ConfigVersionCleanupPayload,
|
|
ConfigVersionCleanupResult,
|
|
ConfigVersionDetail,
|
|
ConfigVersionSummary,
|
|
} from './types';
|
|
|
|
export class ConfigVersionService extends OpenFlareBaseService {
|
|
protected static override readonly basePath: string = '/api/v1/d/config-versions';
|
|
|
|
static list(): Promise<ConfigVersionSummary[]> {
|
|
return this.get<ConfigVersionSummary[]>('/');
|
|
}
|
|
|
|
static getActive(): Promise<ConfigVersionDetail> {
|
|
return this.get<ConfigVersionDetail>('/active');
|
|
}
|
|
|
|
static preview(): Promise<ConfigPreviewResult> {
|
|
return this.get<ConfigPreviewResult>('/preview');
|
|
}
|
|
|
|
static diff(): Promise<ConfigDiffResult> {
|
|
return this.get<ConfigDiffResult>('/diff');
|
|
}
|
|
|
|
static getById(id: string): Promise<ConfigVersionDetail> {
|
|
return this.get<ConfigVersionDetail>(`/${id}`);
|
|
}
|
|
|
|
static publish(force?: boolean): Promise<ConfigVersionDetail> {
|
|
return this.post<ConfigVersionDetail>(
|
|
'/publish',
|
|
undefined,
|
|
force
|
|
? ({ params: { force: true } } as InternalAxiosRequestConfig)
|
|
: undefined,
|
|
);
|
|
}
|
|
|
|
static activate(id: string): Promise<ConfigVersionDetail> {
|
|
return this.post<ConfigVersionDetail>(`/${id}/activate`);
|
|
}
|
|
|
|
static cleanup(
|
|
payload: ConfigVersionCleanupPayload,
|
|
): Promise<ConfigVersionCleanupResult> {
|
|
return this.post<ConfigVersionCleanupResult>('/cleanup', payload);
|
|
}
|
|
} |