2024-05-16 00:58:23 +02:00
|
|
|
import { SystemConfig } from 'src/config';
|
|
|
|
import { Column, DeepPartial, Entity, PrimaryColumn } from 'typeorm';
|
2023-11-25 19:53:30 +01:00
|
|
|
|
|
|
|
@Entity('system_metadata')
|
2024-05-16 00:58:23 +02:00
|
|
|
export class SystemMetadataEntity<T extends keyof SystemMetadata = SystemMetadataKey> {
|
|
|
|
@PrimaryColumn({ type: 'varchar' })
|
|
|
|
key!: T;
|
2023-11-25 19:53:30 +01:00
|
|
|
|
2024-05-16 23:24:54 +02:00
|
|
|
@Column({ type: 'jsonb' })
|
2024-05-16 00:58:23 +02:00
|
|
|
value!: SystemMetadata[T];
|
2023-11-25 19:53:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum SystemMetadataKey {
|
|
|
|
REVERSE_GEOCODING_STATE = 'reverse-geocoding-state',
|
2024-01-04 06:28:32 +01:00
|
|
|
ADMIN_ONBOARDING = 'admin-onboarding',
|
2024-05-16 00:58:23 +02:00
|
|
|
SYSTEM_CONFIG = 'system-config',
|
2024-05-17 18:22:39 +02:00
|
|
|
VERSION_CHECK_STATE = 'version-check-state',
|
2023-11-25 19:53:30 +01:00
|
|
|
}
|
|
|
|
|
2024-05-17 18:22:39 +02:00
|
|
|
export type VersionCheckMetadata = { checkedAt: string; releaseVersion: string };
|
|
|
|
|
2024-05-16 00:58:23 +02:00
|
|
|
export interface SystemMetadata extends Record<SystemMetadataKey, Record<string, any>> {
|
2023-11-25 19:53:30 +01:00
|
|
|
[SystemMetadataKey.REVERSE_GEOCODING_STATE]: { lastUpdate?: string; lastImportFileName?: string };
|
2024-01-04 06:28:32 +01:00
|
|
|
[SystemMetadataKey.ADMIN_ONBOARDING]: { isOnboarded: boolean };
|
2024-05-16 00:58:23 +02:00
|
|
|
[SystemMetadataKey.SYSTEM_CONFIG]: DeepPartial<SystemConfig>;
|
2024-05-17 18:22:39 +02:00
|
|
|
[SystemMetadataKey.VERSION_CHECK_STATE]: VersionCheckMetadata;
|
2023-11-25 19:53:30 +01:00
|
|
|
}
|