import * as XLSX from "xlsx"; import { TypedEmitter } from "tiny-typed-emitter"; import PQueue from "p-queue"; import { ComposanteClientDic } from "./composanteClient.js"; import { clefsExtraction } from "./importateur/json.js"; import type { Constellation } from "./client.js"; import type { conversionDonnées } from "./tableaux.js"; import type { schémaFonctionOublier, schémaFonctionSuivi } from "./types.js"; export type formatTélécharger = XLSX.BookType; export type fréquence = fréquenceFixe | fréquenceDynamique | fréquenceManuelle; export type fréquenceFixe = { type: "fixe"; détails: { unités: "années" | "mois" | "semaines" | "jours" | "heures" | "minutes" | "secondes" | "millisecondes"; n: number; }; }; export type fréquenceDynamique = { type: "dynamique"; }; export type fréquenceManuelle = { type: "manuelle"; }; export type typeObjetExportation = "nuée" | "projet" | "bd" | "tableau"; export type SpécificationAutomatisation = SpécificationExporter | SpécificationImporter; export type copiesExportation = copiesExportationN | copiesExportationTemps; export type copiesExportationN = { type: "n"; n: number; }; export type copiesExportationTemps = { type: "temps"; temps: fréquenceFixe; }; type BaseSpécificationAutomatisation = { fréquence: fréquence; type: "importation" | "exportation"; id: string; }; export type SpécificationExporter = BaseSpécificationAutomatisation & { type: "exportation"; idObjet: string; typeObjet: typeObjetExportation; formatDoc: formatTélécharger; dossier?: string; langues?: string[]; dispositifs: string[]; inclureDocuments: boolean; nRésultatsDésirésNuée?: number; héritage?: ("descendance" | "ascendance")[]; copies?: copiesExportation; }; export type infoImporter = infoImporterJSON | infoImporterFeuilleCalcul; export type infoImporterJSON = { formatDonnées: "json"; clefsRacine: clefsExtraction; clefsÉléments: clefsExtraction; cols: { [key: string]: clefsExtraction; }; }; export type XLSXCommonOptions = { /** * If true, throw errors when features are not understood * @default false */ WTF?: boolean; /** * When reading a file with VBA macros, expose CFB blob to `vbaraw` field * When writing BIFF8/XLSB/XLSM, reseat `vbaraw` and export to file * @default false */ bookVBA?: boolean; /** * When reading a file, store dates as type d (default is n) * When writing XLSX/XLSM file, use native date (default uses date codes) * @default false */ cellDates?: boolean; /** * Create cell objects for stub cells * @default false */ sheetStubs?: boolean; /** * When reading a file, save style/theme info to the .s field * When writing a file, export style/theme info * @default false */ cellStyles?: boolean; /** * If defined and file is encrypted, use password * @default '' */ password?: string; }; export type XLSXParsingOptions = XLSXCommonOptions & { /** Input data encoding */ type?: "base64" | "binary" | "buffer" | "file" | "array" | "string"; /** * Default codepage for legacy files * * This requires encoding support to be loaded. It is automatically loaded * in `xlsx.full.min.js` and in CommonJS / Extendscript, but an extra step * is required in React / Angular / Webpack ESM deployments. * * Check the relevant guide https://docs.sheetjs.com/docs/getting-started/ */ codepage?: number; /** * Save formulae to the .f field * @default true */ cellFormula?: boolean; /** * Parse rich text and save HTML to the .h field * @default true */ cellHTML?: boolean; /** * Save number format string to the .z field * @default false */ cellNF?: boolean; /** * Generate formatted text to the .w field * @default true */ cellText?: boolean; /** Override default date format (code 14) */ dateNF?: string; /** Field Separator ("Delimiter" override) */ FS?: string; /** * If >0, read the first sheetRows rows * @default 0 */ sheetRows?: number; /** * If true, parse calculation chains * @default false */ bookDeps?: boolean; /** * If true, add raw files to book object * @default false */ bookFiles?: boolean; /** * If true, only parse enough to get book metadata * @default false */ bookProps?: boolean; /** * If true, only parse enough to get the sheet names * @default false */ bookSheets?: boolean; /** If specified, only parse the specified sheets or sheet names */ sheets?: number | string | Array; /** If true, plaintext parsing will not parse values */ raw?: boolean; /** If true, ignore "dimensions" records and guess range using every cell */ nodim?: boolean; /** If true, preserve _xlfn. prefixes in formula function names */ xlfn?: boolean; dense?: boolean; PRN?: boolean; }; export type infoImporterFeuilleCalcul = { formatDonnées: "feuilleCalcul"; nomTableau: string; cols: { [key: string]: string; }; optionsXLSX?: XLSXParsingOptions; }; export type SourceDonnéesImportation = SourceDonnéesImportationURL | SourceDonnéesImportationFichier; export type SourceDonnéesImportationAdresseOptionel = SourceDonnéesImportationURL | SourceDonnéesImportationFichierAdresseOptionel; export type SourceDonnéesImportationURL = { typeSource: "url"; url: string; info: T; }; export type SourceDonnéesImportationFichierAdresseOptionel = { typeSource: "fichier"; adresseFichier?: string; info: T; }; export type SourceDonnéesImportationFichier = SourceDonnéesImportationFichierAdresseOptionel & { adresseFichier: string; }; export type SpécificationImporter = BaseSpécificationAutomatisation & { type: "importation"; idTableau: string; dispositif: string; source: SourceDonnéesImportationAdresseOptionel; conversions?: { [idCol: string]: conversionDonnées; }; }; export type SpécificationImporterAvecFichier = SpécificationImporter & { source: SourceDonnéesImportation; }; export type ÉtatAutomatisation = ÉtatErreur | ÉtatÉcoute | ÉtatEnSync | ÉtatProgrammée; export interface ÉtatErreur { type: "erreur"; erreur: string; prochaineProgramméeÀ?: number; } export interface ÉtatÉcoute { type: "écoute"; } export interface ÉtatEnSync { type: "sync"; depuis: number; } export interface ÉtatProgrammée { type: "programmée"; à: number; } type ÉvénementsAutomatisationActive = { initialisée: (args: { fOublier: schémaFonctionOublier; fLancer: () => Promise; }) => void; }; declare class AutomatisationActive extends TypedEmitter<{ misÀJour: () => void; }> { client: Constellation; événements: TypedEmitter<ÉvénementsAutomatisationActive>; état?: ÉtatAutomatisation; fOublier?: schémaFonctionOublier; fLancer?: () => Promise; constructor({ spéc, idSpéc, client, }: { spéc: SpécificationAutomatisation; idSpéc: string; client: Constellation; }); initialiser({ spéc, idSpéc, }: { spéc: SpécificationAutomatisation; idSpéc: string; }): Promise; initialisée(): Promise<{ fOublier: schémaFonctionOublier; fLancer: () => Promise; }>; relancer(): Promise; fermer(): Promise; } type ÉvénementsAutomatisations = { initialisée: (args: { fOublier: schémaFonctionOublier; }) => void; misÀJour: () => void; }; export declare class Automatisations extends ComposanteClientDic<{ [id: string]: SpécificationAutomatisation; }> { automatisations: { [key: string]: { auto: AutomatisationActive; fOublier: () => void; }; }; événements: TypedEmitter<ÉvénementsAutomatisations>; queue: PQueue; fOublier?: schémaFonctionOublier; constructor({ client }: { client: Constellation; }); initialiser(): Promise; initialisée(): Promise<{ fOublier: schémaFonctionOublier; }>; mettreAutosÀJour(autos: SpécificationAutomatisation[]): Promise; obtDonnéesImportation(spéc: SpécificationImporter, résoudreAdresse?: (x?: string) => Promise): Promise; ajouterAutomatisationExporter({ id, typeObjet, formatDoc, inclureDocuments, dossier, langues, fréquence, dispositifs, nRésultatsDésirésNuée, héritage, copies, }: { id: string; typeObjet: typeObjetExportation; formatDoc: formatTélécharger; inclureDocuments: boolean; dossier: string; fréquence: fréquence; langues?: string[]; dispositifs?: string[]; nRésultatsDésirésNuée?: number; héritage?: ("descendance" | "ascendance")[]; copies?: copiesExportation; }): Promise; ajouterAutomatisationImporter({ idTableau, source, fréquence, dispositif, }: { idTableau: string; source: SourceDonnéesImportation; fréquence: fréquence; dispositif?: string; }): Promise; annulerAutomatisation({ id }: { id: string; }): Promise; modifierAutomatisation({ id, automatisation, }: { id: string; automatisation: SpécificationAutomatisation; }): Promise; résoudreAdressePrivéeFichier({ clef, }: { clef?: string; }): Promise; sauvegarderAdressePrivéeFichier({ fichier, }: { fichier: string; }): Promise; suivreAutomatisations({ f, idCompte, }: { f: schémaFonctionSuivi; idCompte?: string; }): Promise; suivreÉtatAutomatisations({ f, }: { f: schémaFonctionSuivi<{ [key: string]: ÉtatAutomatisation; }>; }): Promise; lancerManuellement({ id }: { id: string; }): Promise; fermerAuto(id: string): Promise; fermer(): Promise; } export {};