refactor(db): ♻️ update types to fit recents commits
This commit is contained in:
parent
626bc3c0f6
commit
fa88ab2f68
|
@ -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 link ressources (get, list)
|
||||||
//!TODO Purge unused ressources (delete)
|
//!TODO Purge unused ressources (delete)
|
||||||
|
@ -26,7 +34,10 @@ export class Db {
|
||||||
|
|
||||||
get ressource() {
|
get ressource() {
|
||||||
return {
|
return {
|
||||||
credential: this.#ressourceStorage<Credential>('credential', Credential),
|
credential: this.#ressourceStorage<Credential<CredentialCategory>>(
|
||||||
|
'credential',
|
||||||
|
Credential,
|
||||||
|
),
|
||||||
group: this.#ressourceStorage<Group>('group', Group),
|
group: this.#ressourceStorage<Group>('group', Group),
|
||||||
machine: this.#ressourceStorage<Machine>('machine', Machine),
|
machine: this.#ressourceStorage<Machine>('machine', Machine),
|
||||||
service: this.#ressourceStorage<Service>('service', Service),
|
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 Group ? 'group'
|
||||||
: T extends Machine ? 'machine'
|
: T extends Machine ? 'machine'
|
||||||
: T extends Service ? 'service'
|
: T extends Service ? 'service'
|
||||||
: T extends User ? 'user'
|
: T extends User ? 'user'
|
||||||
: never
|
: never
|
||||||
|
|
||||||
type RessourceBuilder<T extends Ressource> = T extends Credential
|
type RessourceBuilder<T extends Ressource> = T extends
|
||||||
? typeof Credential
|
Credential<CredentialCategory> ? typeof Credential
|
||||||
: T extends Group ? typeof Group
|
: T extends Group ? typeof Group
|
||||||
: T extends Machine ? typeof Machine
|
: T extends Machine ? typeof Machine
|
||||||
: T extends Service ? typeof Service
|
: T extends Service ? typeof Service
|
||||||
|
|
Loading…
Reference in a new issue