diff --git a/types/jsreport-core/index.d.ts b/types/jsreport-core/index.d.ts
index 23413889da..ab0fe38a02 100644
--- a/types/jsreport-core/index.d.ts
+++ b/types/jsreport-core/index.d.ts
@@ -5,92 +5,104 @@
// TypeScript Version: 2.3
///
-import { Buffer } from 'buffer';
-import { Readable } from 'stream';
declare namespace JsReport {
- type helpers = string | { [fun: string]: (...args: any[]) => any };
+ type Helpers = string | { [fun: string]: (...args: any[]) => any };
- interface RenderOptions {
- template: {
- content: string;
- engine: 'jsrender' | 'handlebars' | 'ejs' | 'jade' | string;
- helpers?: helpers;
- recipe: 'phantom-pdf' | 'electron-pdf' | 'text' | 'xlsx' | 'html-to-xlsx' | 'phantom-image' | 'html-to-text' | 'fop-pdf' | 'client-html' | 'wrapped-html' | 'wkhtmltopdf' | string;
- };
- data?: any;
+ type Engine = "none";
+
+ type Recipe = "html";
+
+ interface Template {
+ content: string;
+ engine: Engine | string;
+ helpers: Helpers;
+ recipe: Recipe | string;
}
- interface Report {
+ interface Request {
+ template: Partial;
+ options: object;
+ data: any;
+ }
+
+ interface Response {
content: Buffer;
- stream: Readable;
+ stream: NodeJS.ReadableStream;
headers: {
[header: string]: string | number | boolean;
};
}
- interface Request {
- template: {
- content: string;
- };
- }
-
- // interface Response {
- // // todo
- // }
-
- type Response = any;
-
- interface Listener {
- add(type: string, callback: (req: Request, res: Response, err: any) => void): void;
- }
-
- interface Logger {
- add(logger: any, options?: {
- level: 'debug' | 'info' | 'log' | 'warn' | 'error';
- }): void;
+ interface ListenerCollection {
+ add(
+ type: string,
+ callback: (req: Request, res: Response, err?: any) => Promise | void
+ ): void;
}
interface Collection {
- find(query: {
- [field: string]: any;
- }): Promise;
+ find(query: { [field: string]: any }): Promise