refactor(server): system config (#9517)

This commit is contained in:
Jason Rasmussen
2024-05-15 18:58:23 -04:00
committed by GitHub
parent 7f0f016f2e
commit 984aa8fb41
46 changed files with 599 additions and 770 deletions
@@ -1,20 +1,23 @@
import { Column, Entity, PrimaryColumn } from 'typeorm';
import { SystemConfig } from 'src/config';
import { Column, DeepPartial, Entity, PrimaryColumn } from 'typeorm';
@Entity('system_metadata')
export class SystemMetadataEntity {
@PrimaryColumn()
key!: string;
export class SystemMetadataEntity<T extends keyof SystemMetadata = SystemMetadataKey> {
@PrimaryColumn({ type: 'varchar' })
key!: T;
@Column({ type: 'jsonb', default: '{}', transformer: { to: JSON.stringify, from: JSON.parse } })
value!: { [key: string]: unknown };
value!: SystemMetadata[T];
}
export enum SystemMetadataKey {
REVERSE_GEOCODING_STATE = 'reverse-geocoding-state',
ADMIN_ONBOARDING = 'admin-onboarding',
SYSTEM_CONFIG = 'system-config',
}
export interface SystemMetadata extends Record<SystemMetadataKey, { [key: string]: unknown }> {
export interface SystemMetadata extends Record<SystemMetadataKey, Record<string, any>> {
[SystemMetadataKey.REVERSE_GEOCODING_STATE]: { lastUpdate?: string; lastImportFileName?: string };
[SystemMetadataKey.ADMIN_ONBOARDING]: { isOnboarded: boolean };
[SystemMetadataKey.SYSTEM_CONFIG]: DeepPartial<SystemConfig>;
}