/** * @license * Copyright 2023 Open Ag Data Alliance * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import '@oada/pino-debug'; import { CronJob } from 'cron'; import { ListWatch } from '@oada/list-lib'; import type { OADAClient } from '@oada/client'; import type EmailConfig from '@oada/types/trellis/service/abalonemail/config/email.js'; import type Job from '@oada/types/oada/service/job.js'; import type { Service } from './Service.js'; export interface ReportConstructor { name: string; service: Service; frequency: string; email: EmailConfigSetup; reportConfig: ReportConfig; filter?: (job: Job) => boolean; type?: string; sendEmpty?: boolean; } export declare class Report { #private; name: string; email: EmailConfigSetup; reportConfig: ReportConfig; frequency: string; service: Service; oada: OADAClient; mailer: CronJob; path: string; lastCron: string; sendEmpty?: boolean; type: string | string[] | undefined; listWatchFailures?: ListWatch; listWatchSuccesses?: ListWatch; filter?: (job: Job) => boolean; /** * @param name The name of the report * @param reportConfig The configuration used to derive CSV rows from the jobs list. * @param service The `Service` which the watch is operating under * @param frequency A cron-like string describing the frequency of the emailer. * @param email A callback used to generate the email job * @param type The subservice type to report on * @param filter filter function for report entries * @param sendEmpty configure whether empty reports should be sent (default=false) * / */ constructor(rc: ReportConstructor); sendEmail(ecs?: EmailConfig, lastDate?: string, startDate?: string): Promise; stop(): Promise; start(): void; /** * Generate a report entry for a finished job * @params * @params * @params */ reportItem(report: Report, job: Job, path: string): globalThis.Promise; } export declare function reportOnItem(report: Report, job: Job, path: string): globalThis.Promise; export declare function parseAttachment(buffString: string): unknown[]; export type EmailConfigSetup = () => EmailConfig; export interface ReportConfig { jobMappings: Record; errorMappings: Record; }