import { JSONSchemaType } from "ajv"; import type { objRôles } from "@/accès/types.js"; import type { Constellation } from "@/client.js"; // https://stackoverflow.com/questions/41980195/recursive-partialt-in-typescript export type RecursivePartial = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial[] : T[P] extends object | undefined ? RecursivePartial : T[P]; }; // https://hackernoon.com/mastering-type-safe-json-serialization-in-typescript type PrimitifJson = string | number | boolean | null | undefined; export type Jsonifiable = | PrimitifJson | Jsonifiable[] | { [key: string]: Jsonifiable; }; export interface infoAuteur { idCompte: string; accepté: boolean; rôle: keyof objRôles; } export type élémentsBd = | number | boolean | string | { [clef: string]: élémentsBd } | Array<élémentsBd>; export type TYPES_STATUT = "interne" | "jouet" | "active" | "obsolète"; export type schémaStatut = { statut: TYPES_STATUT; idNouvelle?: string; }; export type TraducsNom = { [langue: string]: string }; export type schémaFonctionSuivi = | ((x: T) => void) | ((x: T) => Promise); export type schémaFonctionOublier = () => Promise; export type schémaRetourFonctionRechercheParProfondeur = { fOublier: schémaFonctionOublier; fChangerProfondeur: (p: number) => Promise; }; export type schémaRetourFonctionRechercheParN = { fOublier: schémaFonctionOublier; fChangerN: (n: number) => Promise; }; export interface infoRésultatTexte { type: "texte"; texte: string; début: number; fin: number; } export interface infoRésultatVide { type: "vide"; } export interface infoRésultatRecherche { type: "résultat"; de: string; clef?: string; info: T; } export type infoRésultat = | infoRésultatTexte | infoRésultatVide | infoRésultatRecherche; export interface résultatObjectifRecherche extends infoRésultatRecherche { score: number; } export interface résultatRecherche { résultatObjectif: résultatObjectifRecherche; id: string; } export type schémaFonctionSuivreObjectifRecherche = ( client: Constellation, id: string, f: schémaFonctionSuiviRecherche, ) => Promise; export type schémaFonctionSuiviRecherche = ( résultat?: résultatObjectifRecherche, ) => Promise | void; export type schémaFonctionSuivreConfianceRecherche = ( id: string, f: schémaFonctionSuivi, ) => Promise; export type schémaFonctionSuivreQualitéRecherche = ( id: string, f: schémaFonctionSuivi, ) => Promise; export type structureBdNoms = { [langue: string]: string }; export const schémaStructureBdNoms: JSONSchemaType = { type: "object", additionalProperties: { type: "string", }, required: [], }; export type structureBdMétadonnées = { [langue: string]: élémentsBd }; export const schémaStructureBdMétadonnées: JSONSchemaType = { type: "object", additionalProperties: true, required: [], }; export type PasNondéfini = T extends undefined ? never : T;