refactor(db): ♻️ update types to fit recents commits

This commit is contained in:
Julien Oculi 2024-06-18 10:07:45 +02:00
parent 626bc3c0f6
commit fa88ab2f68

View file

@ -1,4 +1,12 @@
import { Credential, Group, Machine, Ressource, Service, User } from '@models'
import {
Credential,
Group,
Machine,
type Ressource,
Service,
User,
} from '@models'
import type { CredentialCategory } from '@models/credential.ts'
//!TODO link ressources (get, list)
//!TODO Purge unused ressources (delete)
@ -26,7 +34,10 @@ export class Db {
get ressource() {
return {
credential: this.#ressourceStorage<Credential>('credential', Credential),
credential: this.#ressourceStorage<Credential<CredentialCategory>>(
'credential',
Credential,
),
group: this.#ressourceStorage<Group>('group', Group),
machine: this.#ressourceStorage<Machine>('machine', Machine),
service: this.#ressourceStorage<Service>('service', Service),
@ -110,15 +121,16 @@ export class Db {
}
}
type RessourceType<T extends Ressource> = T extends Credential ? 'credential'
type RessourceType<T extends Ressource> = T extends
Credential<CredentialCategory> ? 'credential'
: T extends Group ? 'group'
: T extends Machine ? 'machine'
: T extends Service ? 'service'
: T extends User ? 'user'
: never
type RessourceBuilder<T extends Ressource> = T extends Credential
? typeof Credential
type RessourceBuilder<T extends Ressource> = T extends
Credential<CredentialCategory> ? typeof Credential
: T extends Group ? typeof Group
: T extends Machine ? typeof Machine
: T extends Service ? typeof Service