From fa88ab2f68c70b33c5a2b0191f24759b6ed79771 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Tue, 18 Jun 2024 10:07:45 +0200 Subject: [PATCH] refactor(db): :recycle: update types to fit recents commits --- src/db/mod.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/db/mod.ts b/src/db/mod.ts index 148d1c2..da80054 100644 --- a/src/db/mod.ts +++ b/src/db/mod.ts @@ -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: this.#ressourceStorage>( + 'credential', + Credential, + ), group: this.#ressourceStorage('group', Group), machine: this.#ressourceStorage('machine', Machine), service: this.#ressourceStorage('service', Service), @@ -110,15 +121,16 @@ export class Db { } } -type RessourceType = T extends Credential ? 'credential' +type RessourceType = T extends + Credential ? 'credential' : T extends Group ? 'group' : T extends Machine ? 'machine' : T extends Service ? 'service' : T extends User ? 'user' : never -type RessourceBuilder = T extends Credential - ? typeof Credential +type RessourceBuilder = T extends + Credential ? typeof Credential : T extends Group ? typeof Group : T extends Machine ? typeof Machine : T extends Service ? typeof Service